Now I have installed the Laravel framework using composer command "composer create-project --prefer-dist laravel/laravel myappname" on a local server and everything works fine. Then with the same composer command installed on the shared hosting but nothing works. When I visit to index page return error:
Failed to load resource: the server responded with a status of 500 ()
When I run command php artisan return error on cosole:
PHP Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in /home/c/cn89872/website.com/public_html/bot/ii/bootstrap/app.php:14
How can be solved my problem?
First of all run this command:composer dump-autoload This command will clean up all compiled files and their paths.
After composer update --no-scripts This command will Skips execution of scripts defined in composer.json
Finally, update your project's dependencies: composer update
Related
Im trying to start a fresh project and am following this guide:
php version: 8.1.9
Composer version: 1.9.0
I'm able to create a project and have tried a few things like installing, updating, updating -- no script, clearing the dump, but it all turns out to me not being able to run php artisan serve
most errors point to the auto load on the fresh load but whenever i've composer dump-autoload and tried and updated and tried this does not solve anything. I've followed this source and cannot find any answers for my solution
Here are my reproduction steps:
visit the laravel install page.
create basic application using composer create-project laravel/laravel example-app
cd into the app
composer update
composer install
when running php artisan serve
error recieved:
PHP Warning:
require(/someapp/vendor/autoload.php): Failed to open stream: No such file or directory in /someapp/artisan on line 18
after running composer dump-autoload
PHP Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found in /Documents/someapp/bootstrap/app.php:14```
I want to create new laravel project by composer. I use composer create-project laravel/laravel new-project command for create new project. then, my project is created following this picture.
I start Laravel's local development server using the Laravel's Artisan CLI serve command (first cd new-project and then php artisan serve command). But I got the following error.
Why is there no vendor folder in this project?!!!
How do I fix this error?
(I used PHP 8.1.10)
You need to issue composer install to install packages which creates the vendor/ folder
I am currently hosting an application on a ubuntu 16.04 server... but when i try to deploy the same code on fresh ubuntu 18.04 server i get the following error on my apache logs
PHP Fatal error: Uncaught ReflectionException: Class view does not exist in /var/www/xxxxxxxxxxxx/public_html/vendor/laravel/framework/src/Illuminate/Container/Container.php:788
navigating to that line of code on my laravel project was
$reflector = new ReflectionClass($concrete);
I cleared the config in bootstrap/cache and ran composer dump-autoload to no avail
run this command in project root :
composer dump-autoload
The answer is to run composer dump-autoload -o. Notice the -o.
Make sure the following folders are writable:
bootstrap/cache
storage/framework/views
Thanks for your help guys the issue is that I never had composer installed on the server all along. Installing composer on the server fixed the issue.
I was developing on my dev machine using Homestead. I committed both my composer.lock and composer.json. During this branch, I added Hashid and LaravelDebugBar to composer for development purposes. Everything worked fine on the development machine.
Once I pulled from master to my production machine, and ran composer update, and I get the following error:
When I type in php artisan migrate or composer update, I get the following error:
PHP Fatal error: Class 'Vinkla\Hashids\HashidsServiceProvider' not found in /var/www/schedulizer/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Vinkla\Hashids\HashidsServiceProvider' not found
I tried composer clear-compiled, composer dump-autoload tried manually requiring the Hashid package, and removing the offending lines in config/app.php and running composer update
I checked the service provider, and it is in my config/app.php..
Instead of running composer update, run composer install on the production machine instead; this will bypass the pre-update hooks that Laravel runs.
Source
If they were dev requirements, then you can conditionally add them to your service providers list by adding them to your AppServiceProvider like such:
// AppServiceProvider.php
public function register()
{
/* ... */
if ($this->app->environment('production')) {
// $this->app->register('');
} else {
$this->app->register('Vinkla\Hashids\HashidsServiceProvider');
}
}
Source
First of all, check if Vinkla\Hashids\HashidsServiceProvider exists. Also, double check all letter (it's always better to copy-paste namespace from documentation). Then try to run this command:
composer dumpauto
If it will not help, run this command:
composer dumpauto -o
I tried php artisan config:clear then I ran composer update and composer install but I got the same error message.
in my case, the problem was in bootstrap/cache/config.php
So I deleted the file manually and mission accomplished.
I try to setup a laravel project using composer with this command
composer create-project laravel/laravel blog "5.1.*"
But i got following error:
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error
[RuntimeException]
Error Output: PHP Warning: require(/home/iwan/blog/bootstrap/../vendor/aut
oload.php): failed to open stream: No such file or directory in /home/iwan/
blog/bootstrap/autoload.php on line 17
PHP Fatal error: require(): Failed opening required '/home/iwan/blog/boots
trap/../vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pea
r') in /home/iwan/blog/bootstrap/autoload.php on line 17
Does anybody know how to fix this ?
Thank you
Actually, the project is created but the dependencies are not installed so open your terminal/command prompt and run following commands:
cd blog
composer install
Also, if you want then, you may install the Laravel installer so you can create a new project using something like the following:
laravel new Blog
This is a little bit faster. So to install the installer you need to run the following command from the command prompt/terminal:
composer global require "laravel/installer=~1.1"
Once you install the installer you may then run laravel new someproject from the terminel to create a new project with all the dependencies (According to Documentation).
Note: Check this and this as well if needed.