Updating the composer.phar on Symfony2 - symfony

I have an already started Symfony2 project. I need to install a new bundle, and as I saw i need to add a new line to my composer.json and then execute the update command.
The thing is, my composer.phar file and the .json are on different folders.
/httpdocs/composer.json
/bin/composer.phar
So after I add this line to the .json file:
"doctrine/mongodb-odm-bundle": "3.0.*#dev"
If then i try /bin/php composer.phar update doctrine/mongodb-odm-bundle i got an error saying that the composer.json is not there and is correct of course. So my doubt is WHY thoose files are in different folders? does the previous developer make a mistake? Should I move the files to a same folder? To bin or httpdocs?

It doesn't matter where the composer.phar lives. The relevant part, that your current working directory is in the symfony project (where the composer.json lives). Then simple execute composer (if the execute bit is set, no call to php is required).
/bin/composer.phar update doctrine/mongodb-odm-bundle

You can have a global composer.phar and use only this one. This is how you would normally have it on a development machine where you have multiple composer projects.
Some people tend to put a composer.phar into their projects so they can deploy it together with their application.
Solution to composer complaining about the missing composer.json:
you have to change your working directory to the path where the composer.json you want to use is located. ( every composer project has it's own composer.json )
This means cd into your project directory ...
cd /path/to/yourproject
... Before executing
/bin/composer.phar update ...
Alternative:
You can specify a working directory for composer with the --working-dir option.
This way you point composer to your project from any current working directory ( even if you project's path differs from where your cwd is ) . example usage:
composer --working-dir=/path/to/yourproject <command>
Tip #1
rename /bin/composer.phar to /bin/composer
mv /bin/composer.phar /bin/composer
chmod +x /bin/composer
Then you can simply ( assuming /bin is in your PATH ) ...
composer <command>
Tip #2
You can check where you currently are with pwd ( *p*rint *w*orking *d*irectory )
pwd

Related

WP composer installation and Unistallation with CLI

I have tried to make a theme, pre-packed from underscore.me, then I have gone the theme root folder. Then command: composer install then I have found 1 folder (vendor) and composer.lock file. Then I can check my project with composer lint:wpcs this command. Now, feel that this vendor & composer.lock file is unnecessary for me.
How can I uninstall them with command line without sudo rm -rf 'bla bla' this command.
Thank you

Laravel-5.7 not create folder resources\views\layouts

I'm using PHP 7.2.12 and Composer 1.7.3.
When I execute the command composer create-project --prefer-dist laravel/laravel my_project the project is created, but the folder resources\views\layouts is not created and neither the files that are inside of it. Any idea what could be the problem?
I found a answer. To create the folder resources\views\layouts I needed execute
php artisan make:auth
this command create the structure initial the layout to login of the laravel
Laravel-5.7 will not create folder
resources\views\layouts by default, you have to create it manually.
Please check this:
http://prntscr.com/lusq6a
Thank you

Symfony 4 - Assets folder not found

According to Symfony Best Practices,
Store your assets in the assets/ directory at the root of your project.
But currently, I don't have this folder created and if I create it, I got the error telling me that ressources can't be found.
I tried composer require webassets , but don't working.
Anyone have the solution ?
Regards
Placing assets folder in root directory is best practice. Reason that root directory cannot be accessible from outside. You should try Symfony's Webpack Encore plugin. It compiles your minimized and compressed assets into public folder so they can never be shown as original.
If that is not fit your interest just put your whole assets folder into public directory.
You try following command.
$ composer require encore
$ yarn install
May be good to refer to here.
http://symfony.com/doc/current/frontend/encore/installation.html
Enable the encore composer require encore
update yarn yarn install

Sync does not exist when run the update.php script

I reproduced demo NewsPlus Lite on my site http://druid888.mcdir.ru,but when I update Drupal core and run the update.php script I get the error:
Configuration directory: sync
The directory sites/default/files/config_2ds9Pl...-wAgFK.../sync does not exist."
Simply add an sync folder in an appropriate place on your filesystem, and add this line to your settings.php (or settings.local.php), e.g.:
$config_directories['sync'] = __DIR__ . '/sync';
Drupal will create appropriate directories during installation in your sites/default or sites/<sitename> folder.
Source: If you have just changed code at Drupal.org

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

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?

Resources