bin/console missing after running composer install - php

Hoping someone could help me out with this one please.
My project (on github https://github.com/irvingswiftj/iceMarkt ) when running composer install, seems to run without a hitch, until running the post update commands. In which I end up with the following error (when adding param -vvv):
Updating the "app/config/parameters.yml" file
Could not open input file: bin/console
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command.
If I now browse my project directory, I can see that bin/console is never created!

I had deleted the bin directory assuming that the executable console file would be created in my next composer install. I was wrong! Don't gitignore your bin/composer file and also make sure that if you are using the symfony 3 folder structure, you don't have .gitignore for the symfony 2 folder structure.

I had the same problem because I was accostumed to add the bin directory to my .gitignore file, because in Symfony2 all bin files (including the ones from other vendors) where placed in that folder, but that is not the case in Symfony3, so we can add the bin directory to our code repositories.
You can solve problem installing a new application (using the symfony installer) and copying the bin directory from this new project to your own project.

Using Symfony 4 / Symfony Flex, you need to install the symfony/console package:
composer require symfony/console
Then use from your project dir:
./bin/console
As the file itself is starting with a shebang #!/usr/bin/env php you can execute it right away without php infront.

With newer versions of Symfony and Flex installed,
composer --force recipes:install symfony/console
This will bring bin/console into existence.
If it's already there but you need to update it, use
composer recipes:update symfony/console
composer recipes
Just lists your recipes.

Related

Syfmony 2.8: You have requested a non-existent parameter "kernel.bundles_metadata"

I am a newbie to PHP, We are trying to upgrade our old Symfony project from 2.6 to 2.8.
After executing the below two commands, When I tried to run the app, I am getting the below exception.
composer update symfony/symfony
composer update
Exception:
ParameterNotFoundException in ParameterBag.php line 84: You have
requested a non-existent parameter "kernel.bundles_metadata".
Could anyone help me with this? TIA.
The below steps solved my problem in Windows 10
Step 1: Remove the vendor folder and run the below commands
composer dump-autoload
composer install --no-scripts
Step 2: Remove the folders available under the cache folder
Step 3: Remove the "boostrap.php.cache" file and recreate the "boostrap.php.cache" file using the below command
php vendor/sensio/distribution-bundle/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
Step 4: Clear the cache for all the environments and run the app
php app/console cache:clear --env=prod/qa/dev

Composer not generating doctrine-migrations PHP file into vendor/bin directory

I have inherited an old legacy system based off Yii 1.1 which has had multiple development teams working on it for the past 10 years so is a bit of a mess with little to no documentation.
Doctrine Migrations have been used in the past and I can get this working on Docker, however on the live EB/EC2 instance, the migrations files will not run from command line.
Command:
php vendor/bin/doctrine-migrations status
Throws error
PHP Warning: require(/var/app/current/site/vendor/bin/doctrine-migrations.php): failed to open stream: No such file or directory in /var/app/current/site/vendor/bin/doctrine-migrations on line 8
PHP Fatal error: require(): Failed opening required '/var/app/current/site/vendor/bin/doctrine-migrations.php' (include_path='.:/usr/share/pear7:/usr/share/php7') in /var/app/current/site/vendor/bin/doctrine-migrations on line 8
Looking at my local environment versus the live server, no doctrine-migrations.php file has been created in vendor/bin on the dev server, which composer should have created and is the file being looked for. Composer install is run during build on every deployment but I can't figure out why it is not auto-generating this file in the vendor/bin directory - just another file called doctrine-migrations which pretty much just requires doctrine-migrations.php:
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace Doctrine\Migrations;
require __DIR__ . '/doctrine-migrations.php';
conposer install install bundle declared in your composer.lock file.
Your composer.lock file is generated when doing your first composer install or a composer update or composer require
Difference may occur between your local environment and production environment.
Indeed, on local, composer install install some bundle only needed in dev mode (see your require-dev part in composer.json)
Either the composer.lock file is not up to date with your composer.json file (if composer.json contain the required bundle) either the required bundle is set as require-dev
To install it, you can run composer install doctrine/doctrine-migrations-bundle

Composer update - Script cache:clear returned with error code 255

My composer update command is returning an error. The problem is coming from vendor folder. I downloaded skeleton project for Symfony 5 and everything seems to be set right.
This is my error in console.
I tried clearing cache folder and deleting vendor folder, than starting command again, but no luck.
Also, when I do composer update --no-scripts as suggested below and docker up the project I get the same error when I try to access it. project browser
welcome on Stackoverflow.
It could happens with some vendor folder when vendor does not implement receipes on flex. Because of error during cache clearing, the composer reinitialized your vendor directory.
You should configure the bundle of vendor. To do that, launch composer update, but do not launch scripts.
composer update --no-scripts
The vendor directory will be copied and won't be anymore deleted.
Then configure the bundle of vendor.
Then execute the cache command manualy.
php bin/console cache:clear
or
symfony console cache:clear
Delete vendor folder
Delete composer.lock
Delete var/cache
Run the composer install command.
If you trying for fresh new pimcore, this might work.

Why isn't bin/console script found nor recreated in "bin" after composer install?

I changed my composer.json and suddenly, when I do
rm -rf vendor/* && rm -rf bin/* && composer update
I get error messages at the end of the process, because the Symfony console isn't found in the folder bin. When I manually copy it there from another project it works, but that cannot be the solution.
The error message is as follows:
....
- Installing symfony/test-pack (v1.0.6): Loading from cache
- Installing symfony/web-server-bundle (v4.3.6): Loading from cache
Generating autoload files
ocramius/package-versions: Generating version class...
ocramius/package-versions: ...done generating version class
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!! Could not open input file: ./bin/console
!!
Script #auto-scripts was called via post-update-cmd
The error is clear, since the bin folder does contain symlinks to loads of other scripts, but not the console script itself.
I tried clearing the composer cache, but it makes no difference.
If I create a complete new empty folder and copy the composer.json file there and run composer install, everything is fine and the console script is in the bin folder, where it should be.
What is the difference?
When I run it later automatically for automatic deployment, how can I be sure, that the console will be there?
First, you should not delete your bin/console script. That's part of your application, it's equivalent to public/index.php but as a console entry point.
Most likely, that file should be kept in your source code repository.
So the best way to guarantee that file will be there when you deploy would be: do not delete it, it's part of your source code and should be kept.
The file is created during install on an empty folder because the flex recipe gets executed during install because of two things:
Flex recipes are only executed during install, not during update.
The flex recipe for symfony/console will copy the whole bin directory to create it anew, but it won't overwrite an existing directory. (Hence, if you keep this directory and its contents on your repo, as you should, it won't be overwritten when you deploy your project on production).

"vendor" folder missing after running "Composer Install"

I am currently trying to run on Vagrant/Homestead a Laravel Application that I pulled from Github. I connected it to the database, and run Composer Install, Composer Update inside the folder. When I try to access to it on the Browser I get the following error:
Warning: require(/home/vagrant/.../public/vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/..../public/autoload.php on line 2
I navigated to the vendor folder and noticed that it was not created. Any ideas how to fix it?
The application runs in Laravel 4, and I got the following output from the terminal when I run Composer Install:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Package herrera-io/json is abandoned, you should avoid using it. Use kherge/json instead.
Package kherge/version is abandoned, you should avoid using it. No replacement was suggested.
Package herrera-io/phar-update is abandoned, you should avoid using it. No replacement was suggested.
Package mjolnic/bootstrap-colorpicker is abandoned, you should avoid using it. Use itsjavi/bootstrap-colorpicker instead.
Generating autoload files
php artisan clear-compiled
php artisan optimize
Generating optimized class loader
Any ideas?
Composer needs to be run from the root of your application, i.e. not from the public folder as your error seems to indicate.
You can first try running:
composer install --no-scripts
This command should list the packages that are being downloaded and installed. If the above works, you can then run:
php artisan optimize
This will create the autoload.php file that Laravel will use.
I also experienced that, i solved the problem by creating a vendor/bin folder inside the Composer directory.
$PATH/users/*-system_name-*/AppData/Roaming/Composer
I got the same problem, some answer are valid but didnt help then i tried a command = composer dump-autoload. Then it works fine. HOPE this helps you the best.

Categories