I have recently installed Laravel 5 via composer. I tried creating a new controller using artisan and I get the following error:
bootstrap/../vendor/autoload.php. Failed to open stream: No such file or directory. The "vendor" folder does not exist.
Am I missing something?
Run composer with --no-scripts
composer update --no-scripts
This shall fix the issue. I tried this on Mac and Linux.
Which OS you are using ?
For Windows :
Go to Command Prompt
set path to www/{ur project}
For me : www/laravel5
Then type this command : composer install
It will automatically install all dependency in vendor/
Run composer install in your root project folder (or php composer.phar install).
Turns out I didn't enable openssl in my php.ini so when I created my new project with composer it was installed from source. I changed that and ran
composer update
now the vendor folder was created.
Did you create a new project or did you clone an existing project?
If you cloned an existing project it's very important to run
composer install
That way all the dependencies that are missing will be installed.
But if you create a new project you should run this command to make a new project using composer
composer create-project laravel/laravel name-of-your-project
I encountered the same problem. It occurred because composer was not able to install the dependencies specified in composer.json file.
try running
composer install
If this does not solve the problem, make sure
the following php modules are installed
php-mbstring
php-dom
To install this extensions run the following in terminal
sudo apt-get install php-mbstring php-dom
once the installation is complete
try running the command in your project root folder
composer install
You need to regenerate autoload.php file. you can use dump-autoload to do that without having to go through an install or update.
use
composer dump-autoload
to generate autoload.php file again in /vendor directory.
Following this below step solved my problem. You may try
composer update --no-scripts
composer update
Just run this inside the directory where you installed your project
composer install
After checking php version and a lot of research , the problem was on Composer side so just run the following command
composer install --ignore-platform-reqs
This solution worked for me. The reason is not to have a vendor folder in your application.
Follow these steps:
if your project has composer.json file, delete it
then run
composer require phpspec/phpspec
That command add vendor folder to your project
go to your project folder via cmd. run the following command
composer update
it will install the missing vendor folder and files in your project.
but in some cases, it gives an error like "Your configuration does not allow connection to ....." in cmd.
for that go to your composer.json file,
change "secure-http": true to "secure-http": false
but in some cases (as was in my case) you may not find such line in your file. for that do the following action:
change "config": {
"preferred-install": "dist"
}
to
"config": {
"preferred-install": "dist",
"secure-http": false
}
and run again composer update command.
hope this will solve problem.
Just run the following commands,
composer update
Or
composer install
When the new project created the laravel require to load vendors to autoload the libraries ,
We use composer update to
composer update
Composer is a dependency manager allows you to delegate responsibility for managing your dependencies to a third party.
Just setup a new project using composer instead of laravel like this:
composer create-project --prefer-dist laravel/laravel myProje
Delete Vendor then composer install
I also had that error. But none of the above solved the issue. So i uninstalled and again installed the composer. Then i did composer update. and the problem was fixed.
You are missing vendor folder, probably its new cloned repository or new project
the vendor folder is populated by composer binary which reads composer.json file or system requirements and installs packaged under vendor folder and create an autoload script that has all classed
composer update
Before you carry out the following instructions you need to make sure you have composer installed globally on your machine;
Open you Mac terminal and run the following command:
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
once composer is installed globally run the following command after you are in the directory of the project:
composer install
once completed in it update and install all the required packages.
I had same problem with laravel and artisan, the solution:
php artisan key:generate
We got an error because we have missing vendor folder in our project, The vendor directory contains our Composer dependencies.
Need /vendor folder because all packages are there and including all the classes Laravel uses, A problem can be solved after following just two steps:
composer update --no-scripts
composer update
--no-scripts: Skips execution of scripts defined in composer.json
composer update: This will check for newer versions of the libraries you required in your project. If a newer version is found and it's compatible with the version constraint defined in the composer.json file, it will replace the previous version installed. The composer.lock file will be updated to reflect these changes.
These two commands, we will Recreate the vendor folder in our project and after that our project will be working smoothly.
I added composer.lock file to .gitignore, after commit that file to repository error is gone :)
my problem is solved by
composer update
composer install
php artisan key:generate
if you any other problem you can clear cache and config
Clear Route cache:
php artisan route:cache
Clear View cache:
php artisan view:clear
Clear Config cache:
php artisan config:cache
Something I realise is your composer.json file will have some sort of script like
"scripts": {
"post-root-package-install": [
"php -r \"copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"pre-update-cmd": [
"php artisan clear-compiled"
],
"post-update-cmd": [
"php artisan optimize"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
what works for me:
"scripts": {
"post-root-package-install": [
"#php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"#php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"#php artisan package:discover"
]
},
removing post install cmd helped running composer install without any issue.
Hope this helps
Cheers!!
I got this when I did composer update instead of composer install.
Delete vendor folder and run composer install command. It is working 100%
In my case I had to enable another extension, namely php_mbstring.dll in the php.ini file before it could work. It's listed under extension=php_mbstring.dll. Find it in the php.ini file and remove the semi-colon (;) in front of it and save the file.
After this run install composer again in the root directory of your Laravel applcication and is should work.
If you are a Windows user you may uninstall Composer. Then install Composer. After that you install Laravel. Maybe it will work.
this works for me:
after installing the project, I open the project's folder and run these two commands
composer update
composer require doctrine/dbal
I don't know if I am relevant -
I have downloaded the Github release of laravel and installed with lando, and failed to start it.
In lando recipe, I had to add php: 8.1 in .lando.yml
name: ltest1
recipe: laravel
config:
webroot: public
php: 8.1
and
$ lando ssh
$ composer install
$ php artisan key:generate
Related
I get this error when I run the php artisan serve command to launch laravel am a beginner in laravel
PHP Warning: require(/home/matynjr/events/vendor/autoload.php): failed to open stream: No such file or directory in /home/matynjr/events/artisan on line 18
PHP Fatal error: require(): Failed opening required '/home/matynjr/events/vendor/autoload.php' (include_path='.:/usr/share/php') in /home/matynjr/events/artisan on line 18
run in your project root folder cmd with composer update command
You need to go to your project room and install dependencies. It says that there is no vendor folder. Vendor folder is a part of composer. It holds dependency files inside.
Run composer install in the project root. It is a good idea to run composer update after that.
If composer install / composer update isn't working for you, try:
composer install --ignore-platform-reqs
OR
composer update --ignore-platform-reqs
After this you should be able to run "php artisan serve".
For faster results you can use
composer update --verbose --prefer-dist
on your root folder run cmd by replacing root directory with cmd
or open new terminal, navigate to your project root folder and follow the steps below
1 run composer install
2 composer update
3 restart your app
4 then run php artisan serve
run composer install in the root directory of your project
In my case, there were some issues in composer.
I resolved it by running this command in cmd in project's root folder:
composer update
In my case, the error emerged because at some point I enter this two commands php "php artisan cache:clear" and "php artisan config:cache".
So, the way a solved my problem was:
Type first "php artisan cache:clear"
php artisan config:cache
npm update
composer update
and that's it.
After composer update I got an error:
In Filesystem.php line 146:
rename(/var/www/bootstrap/cache/packages.phpE7r5E4,/var/www/bootstrap/cache
/packages.php): No such file or directory
Artisan commands don't work anymore. Already tried:
composer du
composer install
composer update
I found the problem, my windows docker (version 2.1.0.3) sometimes fails to execute. I don't know how it looks like the packages.php file just got locked. So here is the recipe to fix:
I restarted windows,
deleted all the files inside bootstrap\cache
started the containers
run artisan optimize
run composer du
Everything went back to work like a magic. :)
run this command: composer dump-autoload This command will clean up all compiled files and their paths.
enter this command in your terminal for clear cache: php artisan cache:clear
For me deleting the composer.lock file and then running composer install fixed the issue.
I had the same error and these commands helped me:
1. composer dump-autoload
2. php artisan cache:clear
3. php artisan optimize:clear
Try:
composer dump-autoload
or:
artisan cache:clear
after you update or make changes to composer.json to refresh everything.
I've been trying to work on a laravel app but I can't even make it start.
I've run composer install, composer global update, composer udpate, composer self-update and several other commands,
I've deleted the vendor folder, the composer.lock file, re-ran composer install and things I've found online to no avail. This is the error I keep getting:
#php artisan package:discover
In Container.php line 779:
Class request does not exist
Script #php artisan package:discover handling the post-autoload-dump event returned with error code 1
Not sure where to go next. Any ideas?
I would suggest you remove your composer itself and re-install the composer. the try install you laravel packages with it.
Try clearing application cache using this command: php artisan cache:clear
The cache:clear command can be used to clear the applications cache files.
Don't worry about your laravel
check composer correctly installed on your system
check composer have access for READ and WRITE in your system
after your sure about things
check your laravel install in your system for PHP you have and find specific you php version composer connected to it (Those who have multi PHP)
then have two option:
composer global require laravel/installer
then laravel new blog or
composer create-project --prefer-dist laravel/laravel blog
then go to folder cd /projectName
Use PHP's built-in development server: php artisan serve
Im trying to implement Laravel ide helper: barryvdh/laravel-ide-helper .
Tried downloading gist, putting it in root folder of my project but it did not work.
Also tried installing it with composer and adding Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class in the config/app.php file.
Both methods didnt work even when I restarted netbeans.
Using Ubuntu and Laravel 5.1.20
Anyone have idea what im doing wrong?
Installing it with composer isn't enough, you still have to generate it with this command:
php artisan ide-helper:generate
Better yet add it as a post-update-cmd to composer.json:
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan ide-helper:generate",
"php artisan optimize"
]
(the other 2 should already be there)
Then whenever you run composer update it will automatically generate a new IDE helper file. Finally, don't forget to add _ide_helper.php to your .gitignore file
I am using windows 7 and trying to install laravel 4.2 using composer. My development environment is EasyPHP, but based on the research I have done, that is not the problem.
Every time I try to create a new laravel project, called "testapp", by running this command in my projects directory:
composer create-project laravel/laravel testapp --prefer-dist
.., the installation is successful up until the point where composer tries to generate the "autoload" files, outputting these lines:
Generating autoload files
Could not open input file: artisan
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output:
If I then navigate to the new folder called testapp created in my projects directory, and run
composer update
or
composer install
I get the same error at the end.
Although composer doesn't seem to be able to run any php artisan command, by navigating to my testapp folder and running:
php artisan {any command here}
I can accomplish any artisan command I want.
After doing some research, I found that the problem is with composer itself. Composer does not know how to find the artisan file.
One suggestion was that I edit the composer.json file so that artisan would be defined by an absolute path rather than a relative path. So I changed this:
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php artisan key:generate"
]
},
to this:
"scripts": {
"post-install-cmd": [
"php C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC11\\data\\localweb\\projects\\testapp\\artisan clear-compiled",
"php C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC11\\data\\localweb\\projects\\testapp\\artisan optimize"
],
"post-update-cmd": [
"php C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC11\\data\\localweb\\projects\\testapp\\artisan clear-compiled",
"php C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC11\\data\\localweb\\projects\\testapp\\artisan optimize"
],
"post-create-project-cmd": [
"php C:\\Program Files (x86)\\EasyPHP-DevServer-14.1VC11\\data\\localweb\\projects\\testapp\\artisan key:generate"
]
},
within the composer.json file in my testapp folder. Now, when running
composer install
I got this output in the command prompt:
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json.
You may be getting outdated dependencies. Run update to update them.
Nothing to install or update
Generating autoload files
Script php C:\Program Files (x86)\EasyPHP-DevServer-14.1VC11\data\localweb\proje
cts\testapp\artisan clear-compiled handling the post-install-cmd event returned
with an error
[RuntimeException]
Error Output:
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-p
lugins] [--no-custom-installers] [--no-scripts] [--no-progress] [-v|vv|vvv|--ver
bose] [-o|--optimize-autoloader] [packages1] ... [packagesN]
Although I first thought that this output meant that changing the composer.json would not solve the problem, I was amazed to find that changing the composer.json worked when the absolute path contained no spaces.
For example. I went to C:\Users\AlexLeung\Desktop, ran
composer create-project laravel/laravel desktestapp --prefer-dist
got the initial error, then updated the composer.json in the new desktestapp folder to look like
"scripts": {
"post-install-cmd": [
"php C:\\Users\\AlexLeung\\Desktop\\desktestapp\\artisan clear-compiled",
"php C:\\Users\\AlexLeung\\Desktop\\desktestapp\\artisan optimize"
],
"post-update-cmd": [
"php C:\\Users\\AlexLeung\\Desktop\\desktestapp\\artisan clear-compiled",
"php C:\\Users\\AlexLeung\\Desktop\\desktestapp\\artisan optimize"
],
"post-create-project-cmd": [
"php C:\\Users\\AlexLeung\\Desktop\\desktestapp\\artisan key:generate"
]
},
, and running
composer install
was then successful. Although this shows I can install laravel if I just install it on a path with no spaces, I need to be able to install it in places under the "Program Files (x86)" directory since that is where EasyPHP, and its Apache web server root, are located. In trying to get the absolute path to work with spaces, I have tried using underscores, which ends up pointing to the wrong path, and \u0020, which generates the same error.
So the question remains:
How can I get composer to recognize the artisan file within the newly created testapp folder?
A set of resulting questions if the first can't be answered:
1. Is there a way to get composer to recognize the artisan file without me needing to change the composer.json to iunclude an absolute path for artisan?
2. Should I even be concerned about having the autoload files generated? (is it even necessary)
3. Would it be okay if I just moved my projects to the desktop (or any other path without spaces) anytime I needed to run composer update or install?
Overall I would like to have a complete installation of laravel and be able to use the convenient composer commands whenever I need to.
Maybe your issue has to do with some kind of permissions because you are trying to run commands inside "C:\Program Files (x86)". Try to deactivate UAC and see if that works.
Also try to run php artisan clear-compiled from the command line. It may not even be an issue with composer but with the PHP path. Verify that your Windows PATH variable knows where your php.exe is located.
I've just tested a clean install in a folder called "C:\MyPrograms\Some kind of folder\" and composer runs as expected, so it's may have nothing to do with spaces.
You can get composer to recognize php artisan, one way or another. My personal experience tells me that having developer tools installed in C:\Program Files is not a good idea because you will keep getting unexpected behaviors. I advice you to instal PHP, Apache, EasyPHP & whatever you need in a new folder (like "C:\MyPrograms").
Anyhow, even if you have PHP and Apache installed in the default program files folder, you can always set your Document Root of Apache to another location and this may also solve your issue.
As for your other questions:
2) Yes, it really is necessary. The autoload files (will be located in vendor/composer/) enable you to work with namespaces and to work with your own classes and never to include() or require() because it will be done by Laravel automatically.
3) I guess you could do that and it will work. But the hassle of moving your entire project every time you need a composer update seems to much trouble and wasted time.
I think you found a bug in Composer.
This line probably is supposed to make the commands used in the hooks executable:
https://github.com/composer/composer/blob/a8adbfeb9fc7861deade782938222714168a22a8/src/Composer/Command/RunScriptCommand.php#L89
I suspect that the result of realpath() with the binary directory will return the correct path, but including spaces. putenv() looks like operating directly on the shell, with it's parameter being "PATH=C:\Path with spaces\somewhere;C:\PreviousPaths\" - this might not be working on Windows.
You should add an issue on Github to get this fixed.
From experience, lots of software is not well prepared to deal with spaces in paths. I recently had to rename all my Jenkins job names because "job name === workspace directory name", and the backup module was acting up on the spaces.