How to detect which file error in Lavel 5 - php

I'm learing laravel 5. A day, when I run php artisan command I got this error
Catchable fatal error: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given, called in C:\xampp\htdocs\premiumlens\vendor\laravel\framework\src\Illuminate\Routing\RoutingServiceProvider.php on line 62 and defined in C:\xampp\htdocs\premiumlens\vendor\laravel\framework\src\Illuminate\Routing\UrlGenerator.php on line 102
Almost application functions work perfect. But may not all. I'm sure the error is not caused by UrlGenerator.php
Now I cant use any artisan functions. How can I detect which file cause this issue.
Thank you !

I think you used url() helper in your config file, find where you put url() helper in your config file and remove it. your problem will be solved. i had this same problem and solved by removing url() form config file..
url('bassets/plugins/highcharts/highcharts.css'),

Related

Ytake Laravel Aspect with Lumen 5.6

I am using Lumen 5.6. When I run any commands or access any functions through Postman I got this error:
Class 'App\Providers\AnnotationConfiguration' not found
When I added this use Ytake\LaravelAspect\AnnotationConfiguration; in AspectServiceProvider.php, the above issue resolved but now I am getting this error.
Type error: Argument 1 passed to Ytake\LaravelAspect\AnnotationConfiguration::__construct() must be of the type array, null given, called in C:\Projects\cs415_api\app\Providers\AspectServiceProvider.php on line 22
I suspect that the following line in AspectServiceProvider returns null.
$app['config']->get('ytake-laravel-aop.annotation')
Any ideas on how to resolve this error?
This issue was resolved here:
https://github.com/ytake/Laravel-Aspect/issues/53

Fatal error: Cannot redeclare route() when running PHPUnit

I got a specific problem with PHPUnit.
I had to write our own route() helper, which I require at the very start of the boot process. It all works fine, because Laravel actually asks if a similar named function already exists whenever generating a helper.
When I try to run tests, I get:
Fatal error: Cannot redeclare route() (previously declared in
E:\laragon\www\fksp\vendor\laravel\framework\src\Illuminate\Foundation\helpers.php:754)
in E:\laragon\www\fksp\app\Http\helpers.php on line 30
And I don't know why. Why does PHPUnit think that the Laravel helper is declared before ours?
I could wrap our function into
if (! function_exists('route')) {}
and it works, but then most likely I will run into problems in the long run with every test that uses the route function?
Any idea or insights how PHPUnit works?

Laravel 5.3 unauthorized() AuthenticationException fatal error

I've followed Laravel 5.3 upgrade guide, which says to add an unauthenticated method in App\Exceptions\Handler.
However, I get the following error when it gets called by the Auth system:
FatalThrowableError in Handler.php line 59:
Type error: Argument 2 passed to App\Exceptions\Handler::unauthenticated() must be an instance of App\Exceptions\AuthenticationException, instance of Illuminate\Auth\AuthenticationException given, called in /Users/Username/Development/ProjectName/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php on line 135
I've been searching for the last half hour and couldn't find a solution.
Any help?
Check how your Handler.php file compares to the 5.3 branch version here: https://github.com/laravel/laravel/blob/5.3/app/Exceptions/Handler.php
Note the unauthenticated() method in Handler.php expects an instance of \Illuminate\Auth\AuthenticationException. Make sure use Illuminate\Auth\AuthenticationException; is included at the top of the file.
In my case, i just deleted whoops... or restore the default Handler.php
I had this Error 500 inexplicable issue while upgrading from Laravel 5.2 to 5.3. No laravel error logs in storage/logs, no Apache error logs. no issue with .env, debug was turned on, no broken .htaccess directives, plus php artisan could not run. Tried everything until I looked in the PHP error logs and found:
PHP Fatal error: Uncaught Error: Undefined constant 'Illuminate\Auth\AuthenticationException' in C:\code\laravel-project\vendor\laravel\framework\src\Illuminate\Container\Container.php:79
So I did what #jon suggested and compared my Handler.php file with the fresh laravel one and found this:
In your App/Exceptions/Handler.php make sure that the classes in the $dontreport array are referenced as either strings in quotes:
'\Illuminate\Auth\AuthenticationException',
'\Illuminate\Auth\Access\AuthorizationException',
'\Symfony\Component\HttpKernel\Exception\HttpException',
'\Illuminate\Database\Eloquent\ModelNotFoundException',
'\Illuminate\Session\TokenMismatchException',
'\Illuminate\Validation\ValidationException',
or this way:
\Illuminate\Auth\AuthenticationException::class,
\Illuminate\Auth\Access\AuthorizationException::class,
\Symfony\Component\HttpKernel\Exception\HttpException::class,
\Illuminate\Database\Eloquent\ModelNotFoundException::class,
\Illuminate\Session\TokenMismatchException::class,
\Illuminate\Validation\ValidationException::class,
For some reason I found mine to not have the quotes and fixing that got rid of the Error 500.

CodeIgniter Database Session Error

When I try to execute any controller of my CodeIgniter project i receive this error:
Fatal error: Class CI_Session_files_driver contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::read) in D:\Git\crud-farm\system\libraries\Session\drivers\Session_files_driver.php on line 49
A PHP Error was encountered
Severity: Error
Message: Class CI_Session_files_driver contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (SessionHandlerInterface::read)
Filename: drivers/Session_files_driver.php
Line Number: 49
Backtrace:
I tried to replace CodeIgniter system files but it didn't work. The problem appears in all projects
Problem solved by restarting Apache.
I attach the url which saved me: http://forum.codeigniter.com/thread-64763.html
In my case i did the following
Restart apache
That's it!
The files in system should not be modified. My files were modified somehow and were throwing error. I resolved my problem as below.
Download fresh codeigniter and extract files
copy system files from fresh codeigniter into your project and overwrite the whole system folder.
This should fix your problem.

PHP + APC + Zend: Classes cannot be found

I can't get APC to work properly with my Zend+Doctrine application. When I turn APC on I get the error:
Fatal error: Access to undeclared static property: Zend_Loader_Autoloader::$_instance in /var/www/libs/Zend/Loader/Autoloader.php on line 92
I've seen lots of people complaining about that but no one seem to have solved their problem, except by this guy: Access to undeclared static property: Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver::
I tried that aproach, upgrading APC from 3.1.3 to 3.1.9. It didn't work for me.
I tried enabling nclude_once_override:
apc.include_once_override = 1
Didn't work either.
I also tried to get APC not to cache Zend_Loader_Autoloader by addint the following line to apc.ini:
apc.filters = Autoloader.php
It solved the primary problem, but caused another one:
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Zend_Loader' not found in /var/www/libs/Zend/Loader/Autoloader.php on line 472 Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Zend_Loader' not found in /var/www/libs/Zend/Loader/Autoloader.php on line 472 Fatal error: Class 'Doctrine_Event' not found in /var/www/libs/Doctrine/Record.php on line 801
Next thing I did was get APC not to cache Zend_Loader
apc.filters = Autoloader.php,Loader.php
Solves the problem above, but other classes can't be found:
Fatal error: Class 'Zend_Exception' not found in /var/www/libs/Zend/Loader.php on line 99
I got APC not to cache Zend_Exception, but other classes won't be found.
Note that the errors occur only from the 2nd time the page loads on, after the cache is cleared. First page load works like a charm.
Anyone faced a similar problem and was able to solve it?
Thank you very much.
You need session_write_close():
\Zend_Session::setSaveHandler($foo);
register_shutdown_function('session_write_close');

Categories