Symfony2: How to update a bundle whose source files have been modified? - symfony

I am using the KNP Pagination Bundle. I customized the twig file in the bundle source. Then I found a better way of doing it without touching the bundle's files.
Unfortunately, now everytime that I do
bin/vendors install
I get the following error:-
"KNP Paginator Bundle" has local modifications. Please revert or commit/push before running this command again.
My .gitignore file has ignored /vendors
And my deps file has the bundle included too.
Is there a way to uninstall a bundle? So that I can reinstall it?
Or what is the best way to solve my problem?

./bin/vendors doesn't care about content of .gitignore. You can fork desired bundle, do your changes there and change deps file to point to your fork instead.
If you still want to use original bundle and just reinstall it, you can either run ./bin/vendors install --reinstall or just delete the bundle folder from vendor directory and run ./bin/vendors install again.

How about using git --reset? The vendors are fetched using git clone after all.
Can you explain what "git reset" does in plain english?

Related

Change Meteor Up start.sh template

Due to install Graphicsmagick at Meteor Up Docker, I need to edit the start.sh (link this: Meteor Up Docker and Graphicsmagick).
I done that at the server and works, but every time I run mupx deploy, my /opt/<appName>/config/start.sh file change to original. I need to change the start.sh template, but I don't know how to do that, how can I change it?
You have to change the file from your local meteor-up template. not sure about mupx, it might be in your global .npm installation folder.
I'm using kadira meteor-up so mine is located at the git cloned folder.

How do I update a drupal module without deleting it first?

How do I upload a new version of a module to my site? If I choose "Install new module" through the administration page I get a message that the module already is installed. There are two work arounds that I have found, but none of them seems ideal and the way you are supposed to do it.
I can delete the old module first, and then upload and install the new version. However, if the modules has data associated with it, then this data will be lost.
I can replace the module files on the server. This doesn't seem such a clean way to do it, I would rather follow a more standard process, if there is any.
So what is the best way to do it?
Thanks!
Make a back-up...just in case.
Put your site in maintance mode.
Overwrite your module files with updated version (delete old module files first)
run /update.php from browser or from console run drush updb if you have drush installed (to make database changes if any and similar stuff).
Put your site in "normal" mode again...check if everything is ok.
https://www.drupal.org/node/250790
MilanG's answer is incorrect on step 3. You don't overwrite, you need to remove the existing modules files, then put the new module files in it's place. This is because new module releases may include removed files, and sometimes if those files aren't removed you have problems.
So...
Make a backup (drush site-archive)
Put site in maintenance mode (drush vset maintenance_mode 0)
Delete the old module's directory entirely (rm -fr path/to/modulename)
Download the latest version of the module (drush dl modulename)
Run update.php (drush -y updb)
Turn off maintenance mode (drush vset maintenance_mode 1)
With drush it's pretty easy to just write a wrapper script and run that by module, so that you could do "drush update-module modulename" and those other steps happen.

Symfony 2 - How to determine the namespace and Bundle name for autoload.php & Appkernel.php

I'm very new to symfony2 and I cannot find this info:
To register a bundle located in my vendor dir, how to determine the namespace and Bundle name for autoload.php & Appkernel.php?
For example, I have downloaded Luiggio's PHPExcel Bundle. I have place it in vendorDir/ExcelBundle/
Where content is:
namespace Liuggio\ExcelBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class LiuggioExcelBundle extends Bundle
{
}
What lines should I put in Appkernel and namespace.php?
This and this does not work:
new Liuggio\ExcelBundle\LiuggioExcelBundle()
//'Liuggio\\ExcelBundle' => array($vendorDir. '/PHPExcel'),
I cannot use composer or github repo at all, too many proxies and restrictions where I am.
You shouldn't place bundles in your vendor directory manually. Let Composer do this for you. Not only does Composer know where vendor libraries / bundles should be located, it also adds them to your autoload files and performs some other automated tasks.
To tell Composer which libraries are required, you should add them to your composer.json:
"require" : {
(...)
"liuggio/ExcelBundle": "~2.0"
},
Next, using the command line, run the composer update command:
$ php composer.phar update
(if you don't have a file composer.phar in your project directory, but you have Composer installed globally instead, use the following:)
$ composer update
This will tell Composer to download the required dependencies, update the autoload script, etc, all automatically. When it's finished, you're ready to go.
If you can't use Composer on your server, then run it locally before you upload your files (although I strongly recommend moving to a server that does allow you to use Composer).
The line you're trying to add to AppKernel.php is correct, however it only works after running Composer (or you'd indeed have to download the files and update the autoloader manually, but I'd strongly recommend against that).
Edit
If you really can't use Composer, do the following:
Place the files of ExcelBundle in the following directory:
vendor/liuggio/ExcelBundle/Liuggio/ExcelBundle
Your line in AppKernel.php was already correct.
Add this line to autoload_namespaces.php:
'Liuggio\\ExcelBundle' => array($vendorDir . '/liuggio/ExcelBundle'),
Last but not least, complain to your system administrator that he's making your work impossible with his stupid security measures.
new Liuggio\ExcelBundle\LiuggioExcelBundle(),
in AppKernel should be working fine.
This is the namespace of the LuiggioExcelBundle class + the class name. Look how your bundles are loaded, its the same.
What's your error?
You say vendorDir/ExcelBundle/ but its vendor/ExcelBundle right?
And what do you mean by namespace.php? :o
https://github.com/liuggio/ExcelBundle ==> there readme is rly easy to understand, it should help you.
For your "proxies and restriction", composer is a powerful tool, I can help you to use it. Download this soft, the free version is enough http://www.frozenway.com/ (if you cant read french, the 1st input in the header is to translate the website, English is Anglais) With this, you wont have any ports restriction.

What causes a fatal: not a git repository error?

I am working on webpage, and I need version tracking, so I'm uploading it to github.
Here is the underlying set up.
https://developers.google.com/appengine/articles/wordpress
Now that I have the base CMS ready to go, I need to get the base code uploaded before I start making changes.
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ pwd
/home/lloydm/Downloads/rtt/rtt-code
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# wordpress/
nothing added to commit but untracked files present (use "git add" to track)
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ ls
app.yaml cron.yaml php.ini wordpress
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ git add .
fatal: Not a git repository: wordpress/wp-content/plugins/../.git/modules/appengine-wordpress-plugin
I've never used github before, so I was just following the github website stuff. I have zero idea what this error means or how to prevent it. I can't find anything that I think is related to it.
You need to set up your git repo correctly.
I think you followed this section "Installing WordPress on your development environment" from the link you provided https://developers.google.com/appengine/articles/wordpress
So what you did was download WordPress into your folder which you set up to be a .git repository. However, the WordPress project builder you downloaded itself contains a .git repository.
Check if you have a /workpress/.git file. It likely contains something like :
gitdir: ../.git/modules/wordpress
If you do, then that explains the error I think.
As for setting it up correctly, there are many tutorials available.
One way is to use Git for theme deployment, rather than having it manage your entire WordPress installation --> http://culttt.com/2013/04/08/how-to-deploy-wordpress-themes-with-git/
Another way is to add wordpress as a submodule http://www.efeqdev.com/website-development/this-is-how-we-version-control-and-deploy-our-wordpress-websites-with-git/
or Just make a ~/Downloads/rtt/rtt-code/wordpress/myWebpage directory and set up a git repo in it. http://www.whistlenet.com/git-for-wordpress/
I think you just need to go into the wordpress folder and then run the git status command. As the directory(rtt-code) is not a git directory but contains within it the git repo, that is wordpress, you are getting this error.
Inside the wordpress folder, all your git commands would work perfectly well...

Symfony 2, adding vendor library (PHPExcel etc.)

In my symfony 2.2 app I wanted to use PHPExcel library. So I downloaded it, and copied contents of Classes library to /vendor/phpexcel directory:
vendor/
phpexcel/
PHPExcel/
PHPExcel.php
After that I added the following to app/autoload.php directly below $loader = require ... line:
$loader = require __DIR__.'/../vendor/autoload.php';
//The following was added
$loader->registerPrefixes(array(
'PHPExcel' => __DIR__ . '/../vendor/phpexcel'
));
// intl
...
Now if I browse to my web app, it returns HTTP Error 500 (Internal Server Error). I read the following post, but wasn't able to solve the problem:
How to use PHPExcel correctly with Symfony 2
Can someone help me correct this?
You should never manually download something and put it in the vendor directory. Composer manages the vendor directory, and hence it should be save to delete this directory and run composer install again. The vendor directory also is excluded from Git by default.
To install PHPExcel using composer, add it to composer.json:
"require": {
...
"phpexcel/phpexcel": "1.7.*"
}
When installed with Composer, you should not need to worry about the autoloading either.
I installed https://github.com/liuggio/ExcelBundle for PHPExcel. Bundle includes PHPExcel (addes related links to composer). You can easily use PHPExcel without wondering what the bundle says. Call new \PHPExcel(); then you move. I hope this bundle helps.
Composer seems to have a problem with SELinux. See this. Though not recommended, setting SELinux to permissive can be a workaraound.

Resources