I have a remote repository that I tried to clone locally using
composer install
This worked fine for installing all the bundles and re-creating the parameters.yml, however I get an error right at the end which seems to be related to the change in directory structure from Symfony2->Symfony3:
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
Could not open input file: app/console
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
Clearing the cache we can do manually but is this the only issue or would there be anything else being terminated that we should be aware of?
For me, this was caused by a change in composer.json.
In sf2 there was a config section specifying the binary directory.
In sf3 this all appears in the "extra" section, mine looks like this:
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
Once I had set symfony-bin-dir to "bin" everything started working.
the problem is the path app/console has moved to bin/console in the third version of Symfony
Related
I have installed laravel packages on staging server and packages working fine. But when i take pull on staging server, it is showing me error that package class not found.
Steps I have followed to resolve issue
I have check in vendor folder as well as in config/app.php, but I got class declaration and package folder is there.
After this when I update composer, my issue get resolved.
Is there any other file which should i look for class defination?
Perform a composer update, then composer dump-autoload.
If the above doesn't solve the problem, change the classmap in your composer.json file such that it contains the project-relative path to your php files:
"autoload-dev": {
"classmap": [
"tests/TestCase.php",
"database/seeds/UserTableSeeder.php" //include the file with its path here
]},
and soon after, perform a composer dump-autoload, and it should work now
I have two projects I am working on, both were setup as git repos, both use composer.
First project uses second as a library.
I configured composer.json in the following way:
... "repositories": [
{"type": "composer", "url":"http://composer.myrepourl.com/repo/private/"},
]
"require": {
"second/second": "dev-B-3"
} ...
There was no problem pulling the project from a repository for the first time. However now I made some changes in second project, pushed to the repo and now want to have them in first project, but for some reason composer pulls from the cache.
I ran composer clear-cache. I tried deleting: vendor folder, /home/user/.composer/cache, cache inside container /root/.composer/, but it still finds a way to clone the second project from cache instead of pulling it from repo.
Any ideas on how to force composer to always pull from repo instead of cloning from cache?
Run
$ composer install --prefer-source
Alternatively, specify your preferred installation method in composer.json generally:
{
"config": {
"preferred-install": "source"
}
}
or specifically for the desired dependency
generally:
{
"config": {
"preferred-install": {
"vendor/package": "source",
"*": "dist"
}
}
}
For reference, see:
https://getcomposer.org/doc/03-cli.md#install
https://getcomposer.org/doc/06-config.md#preferred-install
you should run
composer clear-cache
then
composer update --prefer-source
Ok I have found a solution:
sudo rm -r /home/user/project/vendor
cd %wherever_your_docker_is%
docker-compose stop
docker-compose rm
docker-compose up -d
composer update
I cant run composer install because it fails when executing the post-install-cmd-scripts.
The reason is Symfony 3 moved the console app from the app folder to a bin folder.
I have tried composer clear-cache and composer self-update, so I can verify that I'm running the latest version of composer without any luck... Can anyone help me?
Results from composer diagnose
composer diagnose
Checking composer.json: FAIL
Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance
require.symfony/symfony : unbound version constraints (dev-master) should be avoided
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking composer version: OK
Edit:
Added my composer.json file: Pastie
Extra's part:
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
}
}
Error from Composer:
Could not open input file: app/console
Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-install-cmd event terminated with an exception
[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Could not open input file: app/console
.
Manuall test of bin/composer cache:clear:
bin/console cache:clear
// Clearing the cache for the dev environment with debug true
[OK] Cache for the "dev" environment (debug=true) was successfully cleared.
The problem repo: https://bitbucket.org/Richardh87/messenger
Had the same problem. Found that var directory was missing.
Adding var directory to project root dir solved this for me. It looks like symfony 3 tries to use old project structure if var folder is missing. Hope this can help someone.
try
sudo rm -rf vendor/*
sudo rm -rf composer.lock
then run
composer install
again
Check the extra config key in the composer.json files names as symfony-bin-dir.
So check that the composer contain the correct configuration key, as example:
composer.json
....
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
....
Changing the gitignore worked for me, like this:
# Cache and logs (Symfony3)
/var/cache/*
/var/logs/*
!var/cache/.gitkeep
!var/logs/.gitkeep
# Parameters
/app/config/parameters.yml
/app/config/parameters.ini
# Managed by Composer
/app/bootstrap.php.cache
/var/bootstrap.php.cache
/bin/*
!bin/console
!bin/symfony_requirements
/vendor/
# Assets and user uploads
/web/bundles/
/web/uploads/
# Assets managed by Bower
/web/assets/vendor/
# PHPUnit
/app/phpunit.xml
/phpunit.xml
# Build data
/build/
# Composer PHAR
/composer.phar
I have started a composer project and have included phpspec-st,
when I run the command:
/var/www/yii-video-site/vendor$ bin/phpspec desc videosite/test
I get the message:
Specification for videosite\test created in /var/www/yii-video-site/vendor/spec/videosite/testSpec.php.
But when I run phpspec,
it says test
test
10 ! it is initializable
class test does not exist.
videosite/test
10 ! it is initializable
class videosite\test does not exist.
Do you want me to create `test` for you?
Why isnt it seeing the classes that are already created?
You probably need to set-up your PSR-0/PSR-4 autoloading in your composer.json file. For example, if you had your namespaced classes in a "src" directory: something like src/Videosite/Test.php then you'd set the following for the autoloading in your composer.json:
"autoload": {
"psr-0": { "": "src/" }
}
Also, you are running phpspec from within the vendor/bin, so it may not know where the root of your project is. If you set your bin directory in composer.json, you can run phpspec from the bin directory in the root of your project, instead of from inside vendor/bin:
"config": {
"bin-dir": "bin"
}
I came across the same problem today. I tried to run composer dumpautoload on my terminal and it did solve the problem.
Let's say my package in Laravel is test/test.
I created the package in the workbench and it's been working great following Jason Lewis' tutorial. Now I want to move the package out of
the workbench to the vendor directory. This is where all tutorials fall short, even the laravel docs. I didn't want to use git to move the files, so I simply copied the test/test package from the workbench to the vendor directory (and then deleted it from the workbench). I didn't copy the test/test/vendor folder from the workbench (or any other files I noticed in the .gitignore file). I then ran composer install from my new vendor/test/test directory. I then did a composer dump-autoload from the laravel root directory.
Now when I run my application I get an error that I did not get when the package was in the workbench:
Class 'Test\Test\TestServiceProvider' not found
(this is coming from \bootstrap\compiled.php on line 4121)
I also did a php artisan dump-autoload from the laravel root and I get this same error.
Any ideas? Or can someone lead me to a tutorial that takes the package development all the way to it's final resting point in the vendor directory?
Got it working.
I added:
"psr-0": {
"Test\\Test": "vendor/test/test/src/"
}
to the autoload section in composer.json in the laravel root directory so it looks like this:
"autoload": {
"classmap": [
"app/commands",
"app/controllers",
"app/models",
"app/database/migrations",
"app/database/seeds",
"app/tests/TestCase.php"
],
"psr-0": {
"Test\\Test": "vendor/test/test/src/"
}
},
If I decide to put the package on Packagist later then I might remove this from the autoload and just keep the package referenced in the "require" part of my composer.json. We'll see what happens when I get that far!
I think you can install your packages from your hard drive as from local repository like this:
"repositories": [
{
"type":"vcs",
"url":"/path/to/repo/here"
}
],
"require":{
"me/myrepo":"dev-master"
}