When I try to run the following command in laravel 8,
php artisan config:cache
I'm getting error:
LogicException
Your configuration files are not serializable.
at C:\xampp\htdocs\laravel8\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:71
67▕ require $configPath;
68▕ } catch (Throwable $e) {
69▕ $this->files->delete($configPath);
70▕
➜ 71▕ throw new LogicException('Your configuration files are not serializable.', 0, $e);
72▕ }
73▕
74▕ $this->info('Configuration cached successfully!');
75▕ }
1 C:\xampp\htdocs\laravel8\bootstrap\cache\config.php:1083
Error::("Call to undefined method Illuminate\Validation\Rules\In::__set_state()")
2 C:\xampp\htdocs\laravel8\vendor\laravel\framework\src\Illuminate\Foundation\Console\ConfigCacheCommand.php:67
require()
On question Call to undefined method Illuminate\Validation\Rules\In::__set_state(), Someone has provided a solution by editing the vendor files but it's not a confirmed fix as it will get wiped out once the composer install command reran.
An in-use package was generating a config file which was calling the function Rule::in(['true', 'false']). By Removing the config file and modifying the condition, it is working now.
Related
I was updating my server code and everything worked well, even the migration and seeding.
but when I tried login URL it gave me 404 error so I checked and in that process ran then PHP artisan route: list command in the terminal.
and got the error as below:
PHP artisan route: list
Illuminate\Contracts\Container\BindingResolutionException : Target class [App\Http\Controllers\Api\V1\UserController] does not exist.
at /var/www/html/x/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
801|
802| try {
803| $reflector = new ReflectionClass($concrete);
804| } catch (ReflectionException $e) {
> 805| throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
806| }
807|
808| // If the type is not instantiable, the developer is attempting to resolve
809| // an abstract type such as an Interface or Abstract Class and there is
Exception trace:
1 Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}()
[internal]:0
2 ReflectionException::("Class App\Http\Controllers\Api\V1\UserController does not exist")
/var/www/html/x/vendor/laravel/framework/src/Illuminate/Container/Container.php:803
Please use the argument -v to see more details.
it says the given controller cannot be found. I have personally checked the folder and it exists. the permissions are correct and also if I run the same command in the local machine, I do get the route list on the same code.
have tried composer dump-autoload and composer update still no use of that as the error exists. so what's the real issue here. how to solve this issue?
ok found the real issue. it was as below.
App\Http\Controllers\Api\V1\UserController
WAS CHANGED TO
App\Http\Controllers\API\V1\UserController
I thought only windows are not case sensitive to the Caps and small character. As using Mac, I was never able to find it.
Just occurred to check the route list as it might be the case sensitivity, and it was. My bad :/
When I try to follow the instruction here (https://github.com/beyondcode/laravel-er-diagram-generator) I get the following error.
Symfony\Component\Debug\Exception\FatalThrowableError : Argument 1 passed to BeyondCode\ErdGenerator\GenerateDiagramCommand::getAllModelsFromEachDirectory() must be of the type array, null given, called in vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php on line 96
at vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:101
97|
98| return $modelsFromDirectories;
99| }
100|
101| protected function getAllModelsFromEachDirectory(array $directories): Collection
102| {
103| return collect($directories)
104| ->map(function ($directory) {
105| return $this->modelFinder->getModelsInDirectory($directory)->all();
Exception trace:
1 BeyondCode\ErdGenerator\GenerateDiagramCommand::getAllModelsFromEachDirectory()
vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:96
2 BeyondCode\ErdGenerator\GenerateDiagramCommand::getModelsThatShouldBeInspected()
vendor\beyondcode\laravel-er-diagram-generator\src\GenerateDiagramCommand.php:57
Please use the argument -v to see more details.
I've already opened an issue in the repository.
Screen capture of the error:
Posting for others that may encounter same issue.
Confirm you are using the latest version 1.4.0 of the library
Also if you're using php artisan serve try to stop the server. Run php artisan config:cache, and restart the artisan sever.
Note that the reason why you might need to run php artisan config:cache is because Laravel does cache the app's configurations. if you changed or added new configurations you might explicitly need to clear the configuration cache so that Laravel can cache the new configurations.
If no solution yet. Try this
php artisan vendor:publish --provider=BeyondCode\\ErdGenerator\\ErdGeneratorServiceProvider.
Then repeat step 2.
So, I have an API endpoint /api/v1/xxx that calls a single controller and method.
In the routes/api.php I have added the following logic
if (Auth::guard('api')->guest()) {
Route::post('xxx', 'API\v1\XXController#xx');
} else {
Route::post('xxx', 'API\v1\XXController#xx')->middleware('auth:api');
}
Everything works except when I run composer install, I get the following error:
a#b /var/www/html/test/app13 $ composer install
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postInstall
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
Script php artisan optimize handling the post-install-cmd event returned with error code 1
Removing the lines in routes/api.php does not output that ^ error when I run composer install.
What am I doing wrong?
Thanks for any help.
Key path "file:///var/www/html/test/app13/storage/oauth-public.key" does not exist or is not readable
This above lines says everything, you have laravel/passport installed and enabled but you forget to generate the key,
run command
php artisan passport:install
and it will work just fine.
Hello i recently tried to implement JWT authentication in my app by following this tutorial i found online:
cookie-free-authentication-with-json-web-tokens-an-example-in-laravel-and-angularjs
However when trying to install the following package:
barryvdh/laravel-cors 0.4.x#dev
I got an error exception when trying to run php artisan clear-compiled
and later when i tried to run php artisan vendor:publish
This is the error:
[ErrorException]
trim() expects parameter 1 to be string, array given
Edit: I just removed the package and tried running composer update, had the same error again.
Okay i found the error, it had to do with my routes file:
Route::any(['{url?}'], function($url) {
return view('website/index');
})->where(['url' => '[-a-zA-Z0-9/]+']);
I removed the square brackets and now it works, must have accidentally put it there:
Route::any('{url?}', function($url) {
return view('website/index');
})->where(['url' => '[-a-zA-Z0-9/]+']);
Not gonna delete though, somebody might find this useful lol xD xD
I have Laravel installed and now I keep getting this error everytime I run composer update, php artisan routes, or any composer commands:
Call to undefined method Illuminate\Http\Response::view()
I already searched the internet and tried the following suggested solutions so far and nothing worked:
1) A lot of suggested answer on the net says to delete vendor/compiled.php and run the composer update again. But when I went to vendor folder, I cannot find any compiled.php file there. The only file that exists there is: autoload.php
2) I also tried searching for compiled.php inside storage/framework/ folder and nothing there neither.
3) I even tried running optimize with the --force flag php artisan optimize --force and it shows the same error as above.
4) I looked at boostrap/autoload.php for compiled path and it says $compiledPath = __DIR__.'/cache/compiled.php'; I can only see the boostrap/cache folder and that doesnt have this file.
What is wrong here? I am new to Laravel and I dont understand what this error means. Going by the answers out there, I am going around looking for compiled.php to delete and run the update again and I dont even know if that is the right solution for it. Can someone help me here please on how do I proceed troubleshooting this?
I have Laravel 5.1.6 installed after the update I did yesterday. I also ran the composer dumpautoload command today and I wonder if this error started happening after that. Now any commands in composer is giving the above error.
EDIT:
Now even my browser view of the site is showing the error:
FatalErrorException in Facade.php line 210:
Call to undefined method Illuminate\Foundation\Application::missing()
I also tried deleting the complete vendor folder and composer.lock, and re-ran composer install. Towards the end of the installation when generating autoload files, it showed this error again and stopped.
EDIT 2:
#NehalHasnayeen in the comments got it absolutely right. This error was caused due to app calling the view method on Response class, while the response class had no view method. Once I removed that from my route, it worked. This is my route file:
Route::get('/', function () {
return view('index');
//return View::make('index');
});
Route::group(['prefix' => 'api'], function()
{
Route::resource('authenticate', 'AuthenticateController', ['only' => ['index']]);
Route::post('authenticate', 'AuthenticateController#authenticate');
});
// -------- THIS WAS CAUSING THE ISSUE - REMOVING THIS WORKED AFTER THAT ------
//App::missing(function($exception) {
// return view('index');
//});
It takes me to my final question, why was the catch-all route throwing this error? I read from here that adding the above will redirect all other route requests to index. What is the right method? Did it change in Laravel 5 or have I done something wrong?
For 1st error:
your app is calling view method on Response class, but response class has no view method, so find the file where it is calling this method & remove it & replace it with correct method
For 2nd error:
App::missing is for laravel 4 version, it is removed in laravel 5. To achieve the same in your app\exceptions\handler.php file add this in render method
public function render($request, Exception $e)
{
if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
return response()->view('index', [], 404);
}
return parent::render($request, $e);
}