Laravel and Lumen ACL with Shared Codebase - php

I have two separate projects:
Admin (Laravel 5.4)
API (Lumen 5.4)
with Shared Codebase (database, models...)
In my Admin project I use spatie/laravel-permission, but this package is not available for Lumen i.e. When I try to install package in my Lumen project (API) I got this error:
Fatal error: Uncaught ReflectionException: Class path.storage does not exist in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:681 Stack trace: #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(681): ReflectionClass->__construct('path.storage') #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(565): Illuminate\Container\Container->build('path.storage') #2 /var/www/html/vendor/laravel/lumen-framework/src/Application.php(208): Illuminate\Container\Container->make('path.storage') #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(105): Laravel\Lumen\Application->make('path.storage') #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(800): app('path.storage') #5 /var/www/html/vendor/laravel/lumen-framework/config/view.php(31): storage_path('framework/views') #6 /var/www/html/vendor/laravel/lumen-framework/src/Application.php(575): require('/var/www/html/v...') #7 /var/www/html/ in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 681
Fatal error: Uncaught Symfony\Component\Debug\Exception\FatalErrorException: Uncaught ReflectionException: Class path.storage does not exist in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:681 Stack trace: #0 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(681): ReflectionClass->__construct('path.storage') #1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(565): Illuminate\Container\Container->build('path.storage') #2 /var/www/html/vendor/laravel/lumen-framework/src/Application.php(208): Illuminate\Container\Container->make('path.storage') #3 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(105): Laravel\Lumen\Application->make('path.storage') #4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(800): app('path.storage') #5 /var/www/html/vendor/laravel/lumen-framework/config/view.php(31): storage_path('framework/views') #6 /var/www/html/vendor/laravel/lumen-framework/src/Appli in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 681
Where is the problem? Can I use this package in Lumen?
Or could you suggest me some other package for Role & Permission work in Laravel and Lumen.

I saw that spatie/laravel-permission repository does not support Lumen
try to see if this may be for you
http://www.laraveldoctrine.org/docs/1.2/acl

Related

Deploy error with Laravel project on Shared Hosting (Uncaught RuntimeException: A facade root has not been set)

I'm deploying a laravel project into production enviroment on a shared host using FTP following this tutorial except the creation of the symbolic link beacuse I'm not using the local storage but ran into "Uncaught RuntimeException: A facade root has not been set" error.
Aditional info:
I tried with a new laravel project with the command composer create-project laravel/laravel project_name 9 and deployed without run it in my computer and got the same error, then I tested it on my computer and worked fine.
The host was configured to follow these route: /web/content, where is displayed the public files. I followed the tutorial routing and created a folder with project's name with all files except the public folder contents as showed in the tutorial but I got the error, so I thought that the structure was giving me the error so I rename the laravel public folder to content and now all files are inside in /web and still getting the error.
Server info: Linux/Apache/PHP-8
Development enviroment: Windows 10/XAMPP/PHP-8.1
For development testing I use php artisan serve rather than XAMPP
I've deployed the project in my personal Heroku and all is working fine, as an additional test, I've deployed the project via XAMPP on my computer following the same structure in the point 2 and works fine.
Checking the logs I got this:
Server Logs
[17-Jul-2022 18:40:36 America/Chicago] PHP Fatal error: Uncaught RuntimeException: A facade root has not been set. in /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:334
Stack trace:
#0 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/RegisterErrorViewPaths.php(18): Illuminate\Support\Facades\Facade::__callStatic('replaceNamespac...', Array)
#1 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(626): Illuminate\Foundation\Exceptions\RegisterErrorViewPaths->__invoke()
#2 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(607): Illuminate\Foundation\Exceptions\Handler->registerErrorViewPaths()
#3 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(538): Illuminate\Foundation\Exceptions\Handler->renderHttpException(Object(Symfony\Component\HttpKernel\Exception\HttpException))
#4 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(444): Illuminate\Foundation\Exceptions\Handler->prepareResponse(Object(Illuminate\Http\Request), Object(Symfony\Component\HttpKernel\Exception\HttpException))
#5 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(363): Illuminate\Foundation\Exceptions\Handler->renderExceptionResponse(Object(Illuminate\Http\Request), Object(ParseError))
#6 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(427): Illuminate\Foundation\Exceptions\Handler->render(Object(Illuminate\Http\Request), Object(ParseError))
#7 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(115): Illuminate\Foundation\Http\Kernel->renderException(Object(Illuminate\Http\Request), Object(ParseError))
#8 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/content/index.php(51): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#9 {main}
thrown in /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php on line 334
Laravel Logs
[2022-07-17 18:40:36] laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (InvalidArgumentException(code: 0): Log [] is not defined. at /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Log/LogManager.php:207)
[stacktrace]
#0 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(132): Illuminate\\Log\\LogManager->resolve(NULL, NULL)
#1 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(119): Illuminate\\Log\\LogManager->get(NULL)
#2 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Log/LogManager.php(636): Illuminate\\Log\\LogManager->driver()
#3 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(275): Illuminate\\Log\\LogManager->error('syntax error, u...', Array)
#4 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(415): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(ParseError))
#5 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(113): Illuminate\\Foundation\\Http\\Kernel->reportException(Object(ParseError))
#6 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/content/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#7 {main}
"}
[2022-07-17 18:40:36] laravel.ERROR: syntax error, unexpected token ")" {"exception":"[object] (ParseError(code: 0): syntax error, unexpected token \")\" at /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/symfony/finder/Finder.php:588)
[stacktrace]
#0 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/composer/ClassLoader.php(428): Composer\\Autoload\\includeFile('/mnt/stor2-wc1-...')
#1 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(88): Composer\\Autoload\\ClassLoader->loadClass('Symfony\\\\Compone...')
#2 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(65): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->getConfigurationFiles(Object(Illuminate\\Foundation\\Application))
#3 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php(39): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->loadConfigurationFiles(Object(Illuminate\\Foundation\\Application), Object(Illuminate\\Config\\Repository))
#4 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(239): Illuminate\\Foundation\\Bootstrap\\LoadConfiguration->bootstrap(Object(Illuminate\\Foundation\\Application))
#5 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(153): Illuminate\\Foundation\\Application->bootstrapWith(Array)
#6 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(137): Illuminate\\Foundation\\Http\\Kernel->bootstrap()
#7 /mnt/stor2-wc1-dfw1/406060/2039643domain/web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(111): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
#8 /mnt/stor2-wc1-dfw1/406060/2039643/domain/web/content/index.php(51): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
#9 {main}
"}
UPDATE
By curiosity, tried with Laravel 8 and all work fine, but with Laravel 9 don't and by project's requirements, I'm not allowed to downgrade the Laravel version.
Well I couldn't manage to solve the problem on Laravel 9, so the solution was to downgrade to Laravel 8, maybe the problem is the configuration on the host server.

ReflectionClass error. in Upgrading laravel 5.1 to 5.8

I am following https://medium.com/#info.subashthapa/upgrading-laravel-5-0-to-5-8-1bfec5c8a0e2
to upgrade laravel 5.1 to laravel 5.8 now I have stuck in that error
PHP Fatal error: Uncaught ReflectionException: Class App\Console\Kernel does not exist in D:\xampp\htdocs\cloud\vendor\laravel\framework\src\Illuminate\Container\Container.php:741
Stack trace:
#0 D:\xampp\htdocs\cloud\vendor\laravel\framework\src\Illuminate\Container\Container.php(741): ReflectionClass->__construct('App\\Console\\Ker...')
#1 D:\xampp\htdocs\cloud\vendor\laravel\framework\src\Illuminate\Container\Container.php(631): Illuminate\Container\Container->build('App\\Console\\Ker...', Array)
#2 D:\xampp\htdocs\cloud\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(674): Illuminate\Container\Container->make('App\\Console\\Ker...', Array)
#3 D:\xampp\htdocs\cloud\vendor\laravel\framework\src\Illuminate\Container\Container.php(220): Illuminate\Foundation\Application->make('App\\Console\\Ker...', Array)
#4 D:\xampp\htdocs\cloud\vendor\laravel\framework\src\Illuminate\Container\Container.php(738): Illuminate\Container\Container->Illuminate\Container\{closure}(Object(Illuminat in D:\xampp\htdocs\cloud\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 741
I have found out ReflectionClass; in fresh laravel 5.8 but I didn't get.
I download composer.json from server I surprised its file got invalid json. I don't know how it happens.
I tried copy composer.json to replace old composer.json still I got error ReflectionClass error.
Please Suggest me.

cannot execute php artisan command [php fatal error[

I have a laravel project I installed the composer
and run
composer install
After that I executed the update command
composer update
on the project's root directory, and during the execution on the command
php artisan optimize
I got the error shown in the attached image.
When I try to execute any php artisan command I got the same error too.
Error lines
PHP Fatal error: Uncaught Error: Call to undefined method Illuminate\Support\Facades\Auth::check() in C:\xampp\htdocs\projectx\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:221
Stack trace:
#0 C:\xampp\htdocs\projectx\app\Exceptions\Handler.php(39): Illuminate\Support\Facades\Facade::__callStatic('check', Array)
#1 C:\xampp\htdocs\projectx\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(81): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#3 {main}
thrown in C:\xampp\htdocs\projectx\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 221
PHP Fatal error: Uncaught Error: Call to undefined method Illuminate\Support\Facades\Auth::check() in C:\xampp\htdocs\projectx\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php:221
Stack trace:
#0 C:\xampp\htdocs\projectx\app\Exceptions\Handler.php(39): Illuminate\Support\Facades\Facade::__callStatic('check', Array)
#1 C:\xampp\htdocs\projectx\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(81): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalErrorException))
#2 C:\xampp\htdocs\projectx\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(123): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Symfony\Component\Debug\Exception\FatalErrorException))
#3 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#4 {main}
thrown in C:\xampp\htdocs\projectx\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 221
You could try to use the append_config() helper method in your environment app configuration file:
'providers' => append_config(array(
'LocalOnlyServiceProvider',
))
The command php artisan optimize has been remove in laravel 5.6
see more: https://laravel.com/docs/5.6/upgrade

Cake PHP 3.4 error when bake a model

I've Cake PHP 3.4 application on PHP 5.6.
When I try to bake a mode like this sudo bin/cake bake model my_table it gives below error.
Exception: Plugin WyriHaximus/TwigView could not be found. in [/home/yasith/PROJECTS/GINA/gigstr_backend/vendor/cakephp/cakephp/src/Core/Plugin.php, line 149]
2018-01-13 10:43:17 Error: [Cake\Core\Exception\MissingPluginException] Plugin WyriHaximus/TwigView could not be found. in /home/yasith/PROJECTS/GINA/gigstr_backend/vendor/cakephp/cakephp/src/Core/Plugin.php on line 149
Exception Attributes: array (
'plugin' => 'WyriHaximus/TwigView',
)
Stack Trace:
#0 /home/yasith/PROJECTS/GINA/gigstr_backend/vendor/cakephp/bake/src/Shell/BakeShell.php(58): Cake\Core\Plugin::load('WyriHaximus/Twi...', Array)
#1 /home/yasith/PROJECTS/GINA/gigstr_backend/vendor/cakephp/cakephp/src/Console/Shell.php(497): Bake\Shell\BakeShell->startup()
#2 /home/yasith/PROJECTS/GINA/gigstr_backend/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(230): Cake\Console\Shell->runCommand(Array, true, Array)
#3 /home/yasith/PROJECTS/GINA/gigstr_backend/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(182): Cake\Console\ShellDispatcher->_dispatch(Array)
#4 /home/yasith/PROJECTS/GINA/gigstr_backend/vendor/cakephp/cakephp/src/Console/ShellDispatcher.php(128): Cake\Console\ShellDispatcher->dispatch(Array)
#5 /home/yasith/PROJECTS/GINA/gigstr_backend/bin/cake.php(33): Cake\Console\ShellDispatcher::run(Array)
#6 {main}
The bake is working well in previously and that didn't give any error before.
is that any version issue or how to fix that?

CakePHP and Memcached error - php5.6

I'm trying to migrate our company application from php 5.3 to php 5.6. This app uses cakephp 2.4.3 and memcached, but when I try to execute ./cake bake command, the next error comes up:
Fatal error: Uncaught exception 'CacheException' with message 'Cache engine _cake_core_ is not properly configured.' in /cluster/data/deploy/clickdelivery/current/lib/Cake/Cache/Cache.php:181
Stack trace:
#0 /cluster/data/deploy/clickdelivery/current/lib/Cake/Cache/Cache.php(151): Cache::_buildEngine('_cake_core_')
#1 /cluster/data/deploy/clickdelivery/current/app/Config/core.php(381): Cache::config('_cake_core_', Array)
#2 /cluster/data/deploy/clickdelivery/current/lib/Cake/Core/Configure.php(72): include('/cluster/data/d...')
#3 /cluster/data/deploy/clickdelivery/current/lib/Cake/bootstrap.php(177): Configure::bootstrap(true)
#4 /cluster/data/deploy/clickdelivery/current/lib/Cake/Console/ShellDispatcher.php(136): require('/cluster/data/d...')
#5 /cluster/data/deploy/clickdelivery/current/lib/Cake/Console/ShellDispatcher.php(98): ShellDispatcher->_bootstrap()
#6 /cluster/data/deploy/clickdelivery/current/lib/Cake/Console/ShellDispatcher.php(54): ShellDispatcher->_initEnvironment()
#7 /cluster/data/deploy/clickdelivery/cu in /cluster/data/deploy/clickdelivery/current/lib/Cake/Cache/Cache.php on line 181
Persistent and models directory are created with +W.
Thanks in advance.

Categories