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);
}
Related
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.
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 :/
I created a new project via composer create-project laravel/laravel Test 5.4.* then i go to my browser to see my localhost if its working localhost/test/public and it works it redirect me to the welcome page, but when i tried to test
Route::get('/test', function(){
return 'TEST';
});
Then I go to my localhost/test/public/test it shows me error like
NotFoundHttpException: in RouteCollection.php (line 179)
is it a solved issue?
instead of localhost/test/public/test try localhost/test/public/index.php/test.
of course you can use laravel's own server. it is suitable for most developing usages.
Whenever i try to run any php artisan commands from the command line, I get the following error(s):
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","me
ssage":"Call to a member function connection() on a non-object","file":"C:\\wamp
\\www\\cms\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Eloquent\\Mod
el.php","line":2649}}{"error":{"type":"Symfony\\Component\\Debug\\Exception\\Fat
alErrorException","message":"Call to a member function connection() on a non-obj
ect","file":"C:\\wamp\\www\\cms\\vendor\\laravel\\framework\\src\\Illuminate\\Da
tabase\\Eloquent\\Model.php","line":2649}}
I have specified the Laravel version as 4.1.* in my composer.json but since i can't run artisan, i don't know the exact version.
This problem didn't use to happen before. And the website seems to be running fine, despite of the errors occuring in php artisan. Composer commands also work fine, as far as i can tell.
Any ideas why it is happening now?
This error seems to have happened, because for the mail configuration in app/config/mail.php, I made it to retrieve the values from the database instead of specifying the configuration options directly in that file.
So, I had to check if the function for getting the value is called from the web or from the command line. If the function is called from the command line, I simply returned an empty string.
if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
return '';
}
I need some help installing the template plugin for CI. Ive dowloaded and copyied the files and folders to the right places but a simple
function index()
{
$this->template->render();
}
in my Welcome (fresh install of CI) results in a error and im thinking im suppose to include the template plugin in the config/autoload somewhere?
Ive tried to follow http://williamsconcepts.com/ci/codeigniter/libraries/template/start.html but it does not describe how to intergate the plugin with the system (unless i missed something)
(the error is "Fatal error: Call to a member function render() on a non-object in")
Add it to $autoload['libraries'] in application/config/autoload.php:
$autoload['libraries'] = array('template');