Laravel: Permission denied in laravel Blade File - php

I have the following issue when trying to install Laravel http://laravel.com
Any help, would be greatly appreciated.
Unhandled Exception
Message:
file_put_contents(/Users/alvincrespo/Sites/apollo/storage/views/26bdebca7505781c753aa21663170a1b)
[function.file-put-contents]: failed to open stream: Permission denied
Location:
/Users/alvincrespo/Sites/apollo/laravel/blade.php on line 63 Stack
Trace:
#0 /Users/alvincrespo/Sites/apollo/laravel/laravel.php(40):
Laravel\Error::native(2, 'file_put_conten...', '/Users/alvincre...',
63) #1 [internal function]: Laravel{closure}(2,
'file_put_conten...', '/Users/alvincre...', 63, Array) #2
/Users/alvincrespo/Sites/apollo/laravel/blade.php(63):
file_put_contents('/Users/alvincre...', '...') #3 [internal
function]: Laravel{closure}(Object(Laravel\View)) #4
/Users/alvincrespo/Sites/apollo/laravel/event.php(199):
call_user_func_array(Object(Closure), Array) #5
/Users/alvincrespo/Sites/apollo/laravel/event.php(138):
Laravel\Event::fire('laravel.view.en...', Array, true) #6
/Users/alvincrespo/Sites/apollo/laravel/view.php(325):
Laravel\Event::until('laravel.view.en...', Array) #7
/Users/alvincrespo/Sites/apollo/laravel/view.php(546):
Laravel\View->render() #8
/Users/alvincrespo/Sites/apollo/laravel/response.php(246):
Laravel\View->__toString() #9
/Users/alvincrespo/Sites/apollo/laravel/laravel.php(138):
Laravel\Response->render() #10
/Users/alvincrespo/Sites/apollo/public/index.php(34):
require('/Users/alvincre...') #11 {main}

I would check that the permissions on:
/Users/alvincrespo/Sites/apollo/storage/views/26bdebca7505781c753aa21663170a1b
Allow your application to write to this directory.
Assuming you are on a linux box you could run ls -l to see what the permissions are, and if it is set to read only, change the permissions with chmod.

As you can see in the very good documentation under install, you have to make the directory storage/views writeable.
http://laravel.com/docs/install#installation

Although it’s an old question but I hope this might help someone, here is what solved the problem for me.
sudo chmod -R 754 storage/

check the permissions of /storage directory in the laravel installation. The views directory must have write permisison for the webserver that is it.

Related

Magento 2.4.4 - Error Class does not exist during setup:di:compile

I am trying to run setup:di:compile on Magento 2.4.4, but I am getting a strange error and have no idea where to look or how to debug this.
Here is the code from the error log:
Proxies code generation... 1/9 [===>------------------------] 11% 1 sec 139.0 MiB Repositories code generation... 1/9 [===>------------------------] 11% 1 sec 139.0 MiBClass "Magento\Framework\DB\DataConverter\SerializedToJson" not found #0 /public_html/vendor/composer/ClassLoader.php(444): include() #1 /public_html/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile() #2 [internal function]: Composer\Autoload\ClassLoader->loadClass() #3 /public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(134): class_exists() #4 /public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->includeClass() #5 /public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->extract() #6 /public_html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->getList() #7 /public_html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator->doOperation() #8 /public_html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(216): Magento\Setup\Module\Di\App\Task\Manager->process() #9 /public_html/vendor/symfony/console/Command/Command.php(255): Magento\Setup\Console\Command\DiCompileCommand->execute() #10 /public_html/vendor/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run() #11 /public_html/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand() #12 /public_html/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun() #13 /public_html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun() #14 /public_html/bin/magento(23): Symfony\Component\Console\Application->run() #15 {main}
Tried to redeploy static files and so on, but the issue still persists.
Thanks very much for your help!
I have tried:
clearing generated folder
deploying static content
clearing cache
reindexing
What you can simply do is:
Remove the vendor directory and launch the terminal again and execute the command
composer install
to regenerate all the Magento standard codes. You can check your vendor folder to ensure all dependencies are installed and run the compilation command later to load the dependencies.
Please make sure to backup the previous folder as well for safer side.

Laravel shows 'Permission denied' after local package added

I have successfully installed Laravel 8 in Ubuntu 20.4 (Apache server) and the home page is shown correctly. Then, I have added my local repository to composer.json:
"repositories": [
{
"type": "path",
"url": "/home/kari/kama-web-service"
}
]
and it successfully have installed composer require mypackage/name:
.
.
Discovered Package: mypackage/name
.
.
after that the following error is shown on home page:
ErrorException: include(/var/www/html/rws2/vendor/composer/../mypackage/name/src/KamaWebServiceProvider.php): failed to open stream: Permission denied in file /var/www/html/rws2/vendor/composer/ClassLoader.php on line 480
#0 /var/www/html/rws2/vendor/composer/ClassLoader.php(480): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /var/www/html/rws2/vendor/composer/ClassLoader.php(480): include()
#2 /var/www/html/rws2/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile()
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#4 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(735): spl_autoload_call()
#5 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(669): Illuminate\Foundation\Application->resolveProvider()
#6 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\Foundation\Application->register()
#7 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(649): Illuminate\Foundation\ProviderRepository->load()
#8 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#9 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(237): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap()
#10 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(152): Illuminate\Foundation\Application->bootstrapWith()
#11 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(136): Illuminate\Foundation\Http\Kernel->bootstrap()
#12 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#13 /var/www/html/rws2/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle()
#14 {main}
I'm absolutely sure that the file /var/www/html/rws2/vendor/composer/../mypackage/name/src/KamaWebServiceProvider.php exists.
At first I thought that I should give rw access to my package at /home/kari/kama-web-service so I ran chmod -R 775 /home/kari/kama-web-service and sudo chown -R $USER:www-data /home/kari/kama-web-service commands but nothing happen!
Any idea?
The problem goes back to the issue of ‍‍‍‍‍‍‍‍‍/home/kari permissions. To solve it I ran also:
sudo chown -R $USER:www-data /home/kari

Fatal error: Uncaught ReflectionException: Class config does not exist

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.

Magento migration from Godaddy server to Amazon aws Ubuntu

I migrated magento host server from Godaddy to amazon aws ubuntu . Everything working fine but when user proceed to checkout. An error appears on screen
Error : Warning:
include(/var/www/html/includes/src/Payu_PayuCheckout_Model_Shared.php): failed to open stream: No such file or directory in /var/www/html/includes/src/Varien_Autoload.php on line 93 #0 /var/www/html/includes/src/Varien_Autoload.php(93): mageCoreErrorHandler(2, 'include(/var/ww...', '/var/www/html/i...', 93, Array) #1 /var/www/html/includes/src/Varien_Autoload.php(93): Varien_Autoload::autoload() #2 [internal function]: Varien_Autoload->autoload('Payu_PayuChecko...') #3 [internal function]: spl_autoload_call('Payu_PayuChecko...') #4 /var/www/html/includes/src/__default.php(23435): class_exists('Payu_PayuChecko...') #5 /var/www/html/app/Mage.php(462): Mage_Core_Model_Config->getModelInstance('payucheckout/sh...', Array) #6 /var/www/html/includes/src/Mage_Payment_Helper_Data.php(68): Mage::getModel('payucheckout/sh...') ..........
but same code works fine on godaddy.
Payu module is not enabled. I tried running compilation again also.
Do I missing any Php or Apache configuration ?
Please help me. any suggestion that can resolve this error.
it might be your compilation is creating issue
Go to file
includes/config.php
comment out line
define('COMPILER_INCLUDE_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'src');
with
#define('COMPILER_INCLUDE_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'src');
if not commented
and remove dir includes/src

dbModel read resource does not implement Zend_Db_Adapter_Abstract on magento EE

I know this questions is asked so many times but none of the answers is working for me this time.
Everytime I try to load my magento EE 1.14.2.0 I get:
dbModel read resource does not implement Zend_Db_Adapter_Abstract
Trace:
#0 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(134): Varien_Data_Collection_Db->setConnection(false)
#1 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Config.php(1348): Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Object(Mage_Core_Model_Resource_Website))
#2 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Config.php(1380): Mage_Core_Model_Config->getModelInstance('core_resource/w...', Object(Mage_Core_Model_Resource_Website))
#3 /var/www/vhosts/receptional/htdocs/app/Mage.php(491): Mage_Core_Model_Config->getResourceModelInstance('core/website_co...', Object(Mage_Core_Model_Resource_Website))
#4 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Abstract.php(208): Mage::getResourceModel('core/website_co...', Object(Mage_Core_Model_Resource_Website))
#5 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Abstract.php(213): Mage_Core_Model_Abstract->getResourceCollection()
#6 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/App.php(608): Mage_Core_Model_Abstract->getCollection()
#7 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/App.php(466): Mage_Core_Model_App->_initStores()
#8 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Model_App->_initCurrentStore('swimshop', 'store')
#9 /var/www/vhosts/receptional/htdocs/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#10 /var/www/vhosts/receptional/htdocs/index.php(83): Mage::run('swimshop', 'store')
#11 {main}
I have tried updating permissions for var and media folder to 777 but no luck, I also tried updating permission of my whole magento to 777 but no luck again.
Just to let you know that I am on Nginx server if that helps.
Though you are able to run chmod -R 777 files permissions, it may not be working properly. This error comes because of file permission issues.
Check if SELinux is in permissive mode or not?
sestatus
If it is not in permissive mode use following.
Running the following command should fixe the issue.
chcon -Rv --type=httpd_sys_content_t <web Directry>

Categories