Fatal error: Uncaught ReflectionException: Class "env" does not exist - php

After lunching the command php artisan optimize , i got
fatal error: Uncaught ReflectionException: Class "env" does not exist
I have tried deleting the bootstrap/cache/ and runing composer update but nothing works,
everytime i tried to run a php artisan command/composer command i got the same problem. am really stuck. any help.

You can clear cache using:
php artisan optimize:clear
Or only clear config cache using:
php artisan config:clear
https://dev.to/kenfai/laravel-artisan-cache-commands-explained-41e1

Maybe you have something wrong in your config/database.php file. If it is the case when you run composer update the console will show some error at the end of execution due the config/database.php file

Related

PHP Fatal Error in compiled.php after composer update

I am using laravel 5.1 in my production server. After update my composer, queue listener command starts throwing error as
PHP Fatal error: Cannot redeclare class Illuminate\Support\Traits\Macroable in /var/www/<site-folder>/bootstrap/cache/compiled.php on line 6109
I couldn't find out the problem. My site is working fine, and other artisan commands are working fine. But I can't run my queue. Please suggest me some sollution
You should run Run
php artisan clear-compiled
php artisan optimize
and make you sure you restart your queue.

Migration error: Class 'CreateTasksTable' not found

I have the class but I get an error, why?
As you can see it:
Because you didn't run composer dumpauto command after you ran migrate command.
If you receive a "class not found" error when running migrations, try running the composer dump-autoload command and re-issuing the migrate command.
https://laravel.com/docs/5.2/migrations#running-migrations

Laravel 5.2 php artisan migrate:rollback error

I use Laravel 5.2 and I created database tables by running
php artisan make:migration create_categories_table --create=categories
and
php artisan make:migration create_posts_table --create=posts
and then I run php artisan migrate, and tables are created in database. But after I made some changes in migration file "create_posts_table.php" and run
php artisan migrate:rollback
I got an error:
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'CreatePostsTable' not found
PHP Fatal error: Class 'CreatePostsTable' not found in E:\programfiles\xampp\htdocs\deneme\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php on line 336
my create_posts_table.php is
I tried composer update, composer dump-autoload but that hasn't fixed the problem.
I was getting the same problem. May this helps somebody: run composer dump-autoload before running migrate:rollback.
Before you run a migration, you should run the following commands to make sure cache has been cleared:
php artisan clear-compiled
php artisan optimize
This will make sure your new migration class has been registered correctly.

Laravel 5 migration error

I was using migration with a database. Then i removed that database and created new one. Then i created migration files from the terminal via php artisan make:migration create_users.
Then i came back and tried to run the migration and it throws the following error with php artisan migrate
Error:
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with
message 'The stream or file
"/opt/lampp/htdocs/laravel/storage/logs/laravel.log" could not be
opened: failed to open stream: Permission denied' in
/opt/lampp/htdocs/laravel/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:95
And also a few more.
I googled and found that composer dump-autoload wil work, But it didn't and composer dump-autoload throws the same error.
php artisan migrate:reset throws the same error as php artisan migrate:reset.
Thanks
Change Permission of log folder of laravel
Give Read & Write permission
storage/logs
Changing Database:
1: Change DB name in config/database.php
2: root/.env DB_DATABASE=databasename
It's not the problem of autoloading. It is a problem of file permissions. Check if webserver can write to the storage/logs directory.

Deleting migrations results in an Exception

In my Application, when I run php artisan migrate:make create_location_user_table, then delete the generated file (doesn't matter if I delete the line created in vendor/composer/autoload_classmap.php, the php artisan migrate:refresh command throws an error:
include(<path_to_project>/database/migrations/2015_06_21_105357_create_location_user_table.php): failed to open stream: No such file or directory
After running commands to get rid of the faulty autoload entry, I get an exception. The commands I tried are: composer update, composer dump-autoload, php artisan clear-compiled, php artisan optimize.
PHP Fatal error: Class 'CreateLocationUserTable' not found in <path_to_project>\vendor\laravel\framework\src\Illuminate\Database\Migrations\Migrator.php on line 323
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'CreateLocationUserTable' not found
Go into your mysql database manually (PHPMyAdmin) and remove the migrations table. With the steps you've taken above and doing this should solve your issue

Categories