Autoload issue in PhpStorm and Laravel - php

I have created a Laravel project using PhpStorm but when I open index.php in the browser it shows some errors.
It opens http://localhost:63342/METU/public/index.php but it should be http://localhost:63342/index.php.
Warning: require(C:\Users\ilhan\PhpstormProjects\METU\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\ilhan\PhpstormProjects\METU\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required 'C:\Users\ilhan\PhpstormProjects\METU\bootstrap/../vendor/autoload.php' (include_path='.;C:\php\pear') in C:\Users\ilhan\PhpstormProjects\METU\bootstrap\autoload.php on line 17
What is wrong with my project?

That error generally occurs when you haven't run composer install on a new laravel project. The autoload file it references will be created when you run that command.
As for the URL issue, you want to make sure your localhost is mapped to the /public folder of your laravel project, not mapped to the root of it.

Related

Error while using running chat application in CodeIgniter 4

Downloaded a git repo for a chat application using the below link
Git Repo for Chat Application
Then changed the env file to .env file and also uncommented default database block as shown below.
database.default.hostname = localhost
database.default.database = chat
database.default.username = root
database.default.password =
database.default.DBDriver = MySQLi
Then opened terminal and executed this command php spark migrate
But while executing this error pops up
PS C:\xampp\htdocs\Codeigniter-4-Chat-Tutorial> php spark migrate
PHP Warning: require(C:\xampp\htdocs\Codeigniter-4-Chat-
Tutorial\app\Config/../../vendor/codeigniter4/framework/system/bootstrap.php): failed to
open stream: No such file or directory in C:\xampp\htdocs\Codeigniter-4-Chat-Tutorial\spark on line 44
Warning: require(C:\xampp\htdocs\Codeigniter-4-Chat-
Tutorial\app\Config/../../vendor/codeigniter4/framework/system/bootstrap.php): failed to open
stream: No such file or directory in C:\xampp\htdocs\Codeigniter-4-Chat-Tutorial\spark on line 44
PHP Fatal error: require(): Failed opening required 'C:\xampp\htdocs\Codeigniter-4-Chat-
Tutorial\app\Config/../../vendor/codeigniter4/framework/system/bootstrap.php'
(include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Codeigniter-4-Chat-Tutorial\spark on line 44
Fatal error: require(): Failed opening required 'C:\xampp\htdocs\Codeigniter-4-Chat-
Tutorial\app\Config/../../vendor/codeigniter4/framework/system/bootstrap.php'
(include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\Codeigniter-4-Chat-Tutorial\spark on line 44
PS C:\xampp\htdocs\Codeigniter-4-Chat-Tutorial>
How to resolve this? Any help appreciated.
It looks to me that you didn't run the composer update command after starting the project. So in this case your vendor folder is probably missing a lot of files.
Go to the root of your project in the terminal and run:
$ composer update
And you should be fine.

Running "laravel new" command in laravel project

I accidentally ran the laravel new command in a laravel project, which apparently deleted autoload_real.php
I get these error messages when running php artisan serve:
"PHP Warning: require(C:\xampp\htdocs\e-commerce\vendor\composer/../symfony/polyfill-ctype/bootstrap.php): failed to open stream: No such file or directory in C:\xampp\htdocs\e-commerce\vendor\composer\autoload_real.php on line 66
Warning: require(C:\xampp\htdocs\e-commerce\vendor\composer/../symfony/polyfill-ctype/bootstrap.php): failed to open stream: No such file or directory in C:\xampp\htdocs\e-commerce\vendor\composer\autoload_real.php on line 66
PHP Fatal error: require(): Failed opening required 'C:\xampp\htdocs\e-commerce\vendor\composer/../symfony/polyfill-ctype/bootstrap.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\e-commerce\vendor\composer\autoload_real.php on line 66
Fatal error: require(): Failed opening required 'C:\xampp\htdocs\e-commerce\vendor\composer/../symfony/polyfill-ctype/bootstrap.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\e-commerce\vendor\composer\autoload_real.php on line 66"
Is there a way to get back autoload_real.php?
Just run:
composer update
inside your project, it should fix it.
Check if the file actually exists. If it's missing, but the folder 'symfony/polyfill-ctype' is there and empty, try to delete vendor folder and run composer install again. It might be that composer install crashed previous time and it thinks the package is there. That was the case for me.

autoload.php missing when its there

I have started a new Laravel Project and wanted to test it on my localhost...
When I view the site I get an error message saying:
Warning:
require(C:\xampp\htdocs\public/../Website/vendor/autoload.php): failed
to open stream: No such file or directory in
C:\xampp\htdocs\Website\public\index.php on line 24 Fatal Error:
require(): Failed opening required
'C:\xampp\htdocs\Website\public/../Website/vendor/autoload.php'
(include_path='C:\xampp\php\PEAR') in
C:\xampp\htdocs\Website\public\index.php on line 24
I looked it up, but I found the autoload.php file in all folders and I already tried composer update --no-scrips. I just don't get why it isn't loading the project.
'Website' is the name of my Laravel project folder btw.
I fixed the problem thanks to apokryfos.
In the autoload file the DIR.'/../vendor/autoload.php' was changed to DIR.'/../Website/vendor/autoload.php' which was the wrong path. I don't know how this could happen, but simply deleting the 'Website/' seemed to fix the problem.
Thanks again to apokryfos.
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

Laravel: How to recover deleted folder from vendor directory

I used composer to get the laravelcollective/html dependency. But later on I did not need this and I accidentally deleted the folder myself without asking composer to do it for me. Now, whenever I try to run a local server or issue the update command with composer I get the following error:
[RuntimeException]
Error Output: PHP Warning: require(/media/adeel/643459A034597650/Projects/Laravel/vendor/laravelcollective/html/src/helpers.php): failed to open stream: No such file or directo
ry in /media/adeel/643459A034597650/Projects/Laravel/vendor/composer/autoload_real.php on line 55
PHP Fatal error: require(): Failed opening required '/media/adeel/643459A034597650/Projects/Laravel/vendor/laravelcollective/html/src/helpers.php' (include_path='.:/usr/share/p
hp:/usr/share/pear') in /media/adeel/643459A034597650/Projects/Laravel/vendor/composer/autoload_real.php on line 55
Even though the /laravelcollective directory does not exist anymore I still get this error. I have tried removing the whole vendor folder from my Laravel project and then issued a composer update command but I get this error:
[RuntimeException]
Error Output: PHP Warning: require(/media/adeel/643459A034597650/Projects/Laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /media/
adeel/643459A034597650/Projects/Laravel/bootstrap/autoload.php on line 17
PHP Fatal error: require(): Failed opening required '/media/adeel/643459A034597650/Projects/Laravel/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share
/pear') in /media/adeel/643459A034597650/Projects/Laravel/bootstrap/autoload.php on line 17
It seems the problem was fixed by issuing the install command instead of update. I also removed the composer.lock file from its directory, but I don't think that made a difference.

Cache access issue while installing preproduction on symfony

I am currently trying to install a preproduction branch on my dedicated serveur.
I installed a Symfony version in the /web/preprod directoty of my symfony production project. I managed to link correctly the front controller and the routes, and now I am calling an action in the preprod branch.
I am getting this error message :
Warning:
require_once(/var/www/vhosts/ns21206.ovh.net/citydom/web/preprod/app/cache/prod_new/jms_diextra/proxies/CityDom-APIBundle-Controller-GangController.php):
failed to open stream: No such file or directory in
/var/www/vhosts/ns21206.ovh.net/citydom/web/preprod/app/cache/prod/jms_diextra/controller_injectors/CityDomAPIBundleControllerGangController.php
on line 13
Fatal error: require_once(): Failed opening required '/var/www/vhosts/ns21206.ovh.net/citydom/web/preprod/app/cache/prod_new/jms_diextra/proxies/CityDom-APIBundle-Controller-GangController.php'
(include_path='.:/usr/share/pear:/usr/share/php') in
/var/www/vhosts/ns21206.ovh.net/citydom/web/preprod/app/cache/prod/jms_diextra/controller_injectors/CityDomAPIBundleControllerGangController.php
on line 13
The preprod cache folders are on permission 777.
Not all action aren't working, but this one doesn't.
See Setting up Permissions in this section. Go with the setfacl command.

Categories