centos7.0
laravel 5.1.11
php7.0
"php artisan"
message:
Fatal error: Uncaught ReflectionException: Class log does not exist in /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php:741
Stack trace:
#0 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(741): ReflectionClass->__construct('log')
#1 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('log', Array)
#2 /home/website/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('log', Array)
#3 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(842): Illuminate\Foundation\Application->make('log')
#4 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(805): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php(774): Illuminate\Container\Container->getDependencies(Array, Array)
#6 /home/website/vendor/ in /home/website/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 741
The error was thrown because one of the values in the .env file may have spaces.
Just enclosed any values with space in double quotes.
For example let's assume that this is part of your .env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=This Will Cause An Error
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
....
APP_KEY=This Will Cause An Error will cause this issue because it needs to be in quotes like:
APP_KEY="This Will Work"
Also any space after the values may cause the same issue too
In my case the reason for this error was a missing php extension. Since this missing extension raises an error, the logger tries to log it. This exception appears as a result of no 'log' class resolved from the container. I think this is a Laravel bug.
Check your Apache user and file system user first.
Then run the following commands to set file system permissions:
sudo chmod 755 storage -R
sudo chmod 755 vendor -R
sudo chmod 755 bootstrap -R
After you finished changing the file permissions, clean your chache with the following commands:
php artisan config:cache
php artisan cache:clear
php artisan config:clear
This works for me.
Related
I have a problem with laravel and I don't know how to fix it for now. Actually I don't know how I face this problem, but will try to explain you what I did and what I tried for now to fix the problem.
I tried composer update and this problem occured.
Now I can not type any command like php artisan make:livewire name or even php artisan --version, everytime when I try to execute commands I receive this error in console
In Container.php line 811:
Target class [view] does not exist.
In Container.php line 809:
Class view does not exist
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
Also the information from the log file
[previous exception] [object] (ReflectionException(code: -1): Class view does not exist at /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:809)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(809): ReflectionClass->__construct()
#1 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\\Container\\Container->build()
#2 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve()
#3 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(637): Illuminate\\Foundation\\Application->resolve()
#4 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make()
#5 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(1284): Illuminate\\Foundation\\Application->make()
#6 /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(198): Illuminate\\Container\\Container->offsetGet()
#7 /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(166): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance()
#8 /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(255): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#9 /var/www/vendor/beyondcode/helo-laravel/src/HeloLaravelServiceProvider.php(41): Illuminate\\Support\\Facades\\Facade::__callStatic()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(627): BeyondCode\\HeloLaravel\\HeloLaravelServiceProvider->register()
#11 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\\Foundation\\Application->register()
#12 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(604): Illuminate\\Foundation\\ProviderRepository->load()
#13 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\\Foundation\\Application->registerConfiguredProviders()
#14 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\\Foundation\\Bootstrap\\RegisterProviders->bootstrap()
#15 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\\Foundation\\Application->bootstrapWith()
#16 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#17 /var/www/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#18 {main}
"}
Solutions I have been tried till now:
1.Delete vendor folder and type composer install again but at the final stage I received this error again.
2.Delete vendor and composer.lock still without success.
3.Cleaned boostrap/cache/*.php folder and run commands again, but it not worked again.
So any advice how to fix this problem will be appreciated.
Laravel Version: 7
The whole problem was that, another developer had commented line
Illuminate\View\ViewServiceProvider::class, inside config/app.php providers
For me this error occurred after having executed php artisan optimize:clear.
All I had to do to fix it was to execute php artisan view:cache
I solve this problem in my app (Laravel 8, php 7.4 online server) following the steps below:
access my server over ssh
execute this command for the installer composer:
curl -sS https://getcomposer.org/installer | php
change the name of composer.phar for composer. Follow the stpes below:
mkdir ~/bin
mv ~/composer.phar ~/bin/composer
now execute this command for apache PHP
export PATH=$PATH:/var/www/bin
echo 'export PATH=$PATH:/var/www/bin' >> ~/.bashrc
Now test using the command
composer about
Perfect! Now do you need delete your folder VENDOR, and run the command below :
composer update
Voila! try access you application again
One can also run composer install and it could also fix some versions of this error.
I'm working on an e-commerce project on Laravel 5.8, but since I accidently ran "laravel new" command on the project's folder I get this error when I'm trying to launch the project on a local server:
Fatal error: Uncaught ReflectionException: Class config does not exist in C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php:788
Stack trace:
0 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(788): ReflectionClass->__construct('config')
1 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(667): Illuminate\Container\Container->build('config')
2 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(615): Illuminate\Container\Container->resolve('config', Array)
3 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(767): Illuminate\Container\Container->make('config', Array)
4 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(1227): Illuminate\Foundation\Application->make('config')
5 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Log\LogManager.php(417): Illuminate\Container\C in C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 788"
The error on line 788 refers to that portion of code:
$reflector = new ReflectionClass($concrete)
This happened after I cloned my repo from Github. Now for every project that I try to run on a local server I get this error.
I tried "composer install", "composer update", "composer dump-autoload" but they all give the same error with this line at the end:
"Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255".
I checked the .env file to see if there was a namespace issue too, but there's none of it.
Thank you in advance for your help.
Try to remove de files in:
cd bootstrap/cache/
rm -rf *.php
In this directory are the file that initializes the structure, cache directory that contains structure-generated files for performance optimization, such as files and route cache services.
You may check the following items
Check whether your APP_NAME has space. If space is there, use it in quotes.
Delete everything from bootstrap/cache/ folder.
run composer dump-autoload
Hope it will work
I tried #gulCunha 's answer and it worked.
After that, you have to run composer update in order to create a new composer.lock and php artisan config:cache after that and you should be good to go.
Did you change the .env file,mistakenly I have added a "APP_NAME=aaa aa " with spaces, then checked every where, after that APP_NAME= changed without spaces, now working charm.
I was creating a new Laravel 9 project with composer and got the same error.
Fatal error: Uncaught ReflectionException: Class "config" does not exist in .../vendor/laravel/framework/src/Illuminate/Container/Container.php:875
Stack trace:
#0 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(875): ReflectionClass->__construct('config')
#1 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\Container\Container->build('config')
#2 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve('config', Array, true)
#3 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\Foundation\Application->resolve('config', Array)
#4 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make('config', Array)
#5 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(1415): Illuminate\Foundation\Application->make('config')
#6 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(515): Illuminate\Container\Container->offsetGet('config')
#7 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(566): Illuminate\Log\LogManager->getDefaultDriver()
#8 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(119): Illuminate\Log\LogManager->parseDriver(NULL)
#9 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(702): Illuminate\Log\LogManager->driver()
#10 .../vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(274): Illuminate\Log\LogManager->log('error', 'substr(): Argum...', Array)
#11 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(367): Illuminate\Foundation\Exceptions\Handler->report(Object(TypeError))
#12 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Foundation\Console\Kernel->reportException(Object(TypeError))
#13 .../artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 {main}
Next Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist. in .../vendor/laravel/framework/src/Illuminate/Container/Container.php:877
Stack trace:
#0 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\Container\Container->build('config')
#1 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve('config', Array, true)
#2 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\Foundation\Application->resolve('config', Array)
#3 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make('config', Array)
#4 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(1415): Illuminate\Foundation\Application->make('config')
#5 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(515): Illuminate\Container\Container->offsetGet('config')
#6 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(566): Illuminate\Log\LogManager->getDefaultDriver()
#7 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(119): Illuminate\Log\LogManager->parseDriver(NULL)
#8 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(702): Illuminate\Log\LogManager->driver()
#9 .../vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(274): Illuminate\Log\LogManager->log('error', 'substr(): Argum...', Array)
#10 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(367): Illuminate\Foundation\Exceptions\Handler->report(Object(TypeError))
#11 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Foundation\Console\Kernel->reportException(Object(TypeError))
#12 .../artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 {main}
thrown in .../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 877
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
But this time it was not about the cache. Regardless of what the errors suggest, the problem was actually caused by the following lines found in vendor/vlucas/phpdotenv/src/Util/Str.php
$converted = $encoding === null ?
#\mb_convert_encoding($input, 'UTF-8') :
#\mb_convert_encoding($input, 'UTF-8', $encoding);
It actually occurred as I didn't have Multibyte String enabled when I built my PHP binaries. After rebuilding PHP with --enable-mbstring, the problem went away.
Make sure your .env file is the exact same as in your local environment. Make sure that the values on your .env file don't have spaces. Those that have spaces should be wrapped in quotes
I had a similar problem. Here is how I fixed it.
It started when I installed Toastr in my config/app.php providers.
I had failed to add the trailing ",".
Hence the problem.
Solution:
Check the last package you installed.
Check if you have added it correctly in the service providers.
You should run 'composer update' command, and then 'php artisan optimize' to clear the config cache and routes.
I looked everywhere on the web and just couldn't find a solution.
I am getting this error:
Warning: fopen(/var/www/html/includes/../log/404/log_2018-04-07.txt): failed to open stream: Permission denied in /var/www/html/vendor/katzgrau/klogger/src/Logger.php on line 167
Fatal error: Uncaught exception 'RuntimeException' with message 'The file could not be opened. Check permissions.' in /var/www/html/vendor/katzgrau/klogger/src/Logger.php:134 Stack trace:
#0 /var/www/html/includes/db_class.php(7204): Katzgrau\KLogger\Logger->__construct('/var/www/html/i...')
#1 /var/www/html/includes/db_class.php(7217): db_class->getLogger('404')
#2 /var/www/html/includes/furl_router.php(55): db_class->logger('404')
#3 /var/www/html/includes/furl_router.php(229): goTo404('no page-data / ...')
#4 /var/www/html/index.php(17): require_once('/var/www/html/i...')
#5 {main} thrown in /var/www/html/vendor/katzgrau/klogger/src/Logger.php on line 134
From what I read here it's a permission issue but I can't figure it out. I granted all permissions from root folder, I have no idea what am I doing wrong.
Check folder write permissions. Maybe the user trying to write the log has no permissions. sudo chmod -R 666 logs gives read and write permissions to all users.
For anyone using Katzgrau\KLogger\Logger and using relative paths to locate the log file, use an absolute path, e.g.:
$logger = new Logger(__DIR__ . '/../../logs');
After reading a bit about another issue I had but with a MySQL function, after exploring, I figured out I should use MySQL version 5.6 while I used version 5.7.
I uninstalled MySQL 5.7 and install 5.6 instead. It solved both the MySQL issue and the issue mentioned above.
I used Ubuntu Desktop to be my server hosting Magento. I have restored the Magento in following way:
Import Magento database to MySQL server
Copy and paste all the files to /var/www/html
Remarks:
Permission: 755
Magento Version: 1.9.2
PHP version: 7.0
Unfortunately, I have got an error related to the code generated by Magento.
Fatal error:
Uncaught Error: Call to a member function extend() on boolean in /var/www/html/lib/Varien/Simplexml/Config.php:600
Stack trace:
#0 /var/www/html/app/code/core/Mage/Core/Model/Config.php(278): Varien_Simplexml_Config->extend(Object(Mage_Core_Model_Config_Base))
#1 /var/www/html/app/code/core/Mage/Core/Model/App.php(391): Mage_Core_Model_Config->loadBase()
#2 /var/www/html/app/code/core/Mage/Core/Model/App.php(304): Mage_Core_Model_App->_initBaseConfig()
#3 /var/www/html/app/code/core/Mage/Core/Model/App.php(348): Mage_Core_Model_App->baseInit(Array)
#4 /var/www/html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#5 /var/www/html/index.php(83): Mage::run('', 'store')
#6 {main} thrown in /var/www/html/lib/Varien/Simplexml/Config.php on line 600
How can I solve this error in order to restore Magento on a new domain?
I have tried to lower the permission to 644 but it failed. Moreover, I have tested that PHP7.0 can also open the installation page of a new Magento.
Although you have tried to set permissions of folders and files but still it seems to be a problem with folder and file permission.
Please try resetting permission using magento-cleanup.php
file.
Please put this file in document root of your magento and run this file from browser.
Please let me know whether it solves your problem or not.
This will help:
Try clearing cache, and check file permissions are correctly set,
Directories : 755
Files : 644
If this still doesn't work then may be your files are corrupt.
I am trying to execute my first application in cakephp, but it's giving an error
Fatal error: Uncaught exception 'CacheException' with message 'Cache
engine _cake_core_ is not properly configured.' in
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php:166 Stack trace:
#0 /opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php(136): Cache::_buildEngine('_cake_core_') #1
/opt/lampp/htdocs/CakeTooDoo/app/Config/core.php(336):
Cache::config('_cake_core_', Array) #2
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Core/Configure.php(78):
include('/opt/lampp/htdo...') #3
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/bootstrap.php(171):
Configure::bootstrap(true) #4
/opt/lampp/htdocs/CakeTooDoo/app/webroot/index.php(92):
include('/opt/lampp/htdo...') #5 {main} thrown in
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php on line 166
and two warnings
Warning: _cake_core_ cache was unable to write 'cake_dev_en-us' to
File cache in /opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Cache.php on
line 310
Warning: /opt/lampp/htdocs/CakeTooDoo/app/tmp/cache/persistent/ is not
writable in
/opt/lampp/htdocs/CakeTooDoo/lib/Cake/Cache/Engine/FileEngine.php on
line 337
Pleas give me any solution to do my first application with cakephp.
you can use a permissive ownership:
chmod -R 777 app/tmp
A better method is to change group ownership of tmp and everthing below it to www-data ( or whatever group your apache server runs in ) with 'chgrp -R www-data tmp' followed by 'chmod -R 774 tmp' This makes tmp read/write for you and the www-data group but readonly for everyone else
let me know if i can help you more.
The cache folder is not writable according to warning.
open terminal, run sudo chmod 777 /opt/lampp/htdocs/CakeTooDoo -R
Plus, you should reconfigure file permissions, like 775, in real productions.