That's not a breaking-mind thing but it's really annoying:
public function render(){
return view('home')->extends('layout.app')->section('content');
}
The error is
Undefined method 'extends'.
That's not even the only "fake error" i get but it's the only one in this project.
Does anyone know how to fix that?
Related
I have a strange problem in a symfony 5.3.10 app and i can't wrap my head around it.
If I trigger a 500 error, like so:
/**
* #Route("/", name="pvr_index", methods={"GET"})
*/
public function index(): Response
{
echo $a;
Where $a is not defined, in dev environment I get a nice error page.
I'd expect that in prod I would get a not so nice error page that just tells me that i have a 500 error. And this would happen correctly until some time ago, when something changed, but I don't know what.
Now instead I get no error, not even in the symfony server console, and the script execution would keep on going like nothing happened.
What I have tried:
Adding the supposed exception inside a try/catch:
try {
echo $a;
}
catch (\Exception $e)
{
dump($e);
die();
}
Nothing happens, the catch isn't triggered.
Creating an exception listener:
In services.yaml i have:
exception_listener:
class: App\Event\ExceptionListener
tags:
- { name: kernel.event_listener, event: kernel.exception }
And in ExceptionListener.php i have:
class ExceptionListener
{
public function __construct(Environment $engine) {
$this->engine = $engine;
}
public function onKernelException(ExceptionEvent $event)
{
dd($event->getThrowable()->getMessage());
}
}
Still nothing happens, the listener isn't triggered.
Everything works as expected in dev environment, the problem presents itself only in prod.
Looking at a phpinfo(); page I see that the error reporting is enabled, so I think that the problem lies in the symfony configuration.
I'm using php 7.4 and have no real access to the php.ini file
This is not a Symfony error (nor a PHP error for that matter).
On PHP 7.4, trying to output an undefined variable would only raise a notice, not a fatal error (code 500). Notices are silently swallowed up by the engine unless you configure your server to log them or output them, where you'd get something like:
Notice: Undefined variable: a in file xxx.php line Y
A try/catch won't do anything for you, since no exception is thrown for you to catch.
Even on PHP 8 or 8.1, this will only raise a warning like:
Warning: Undefined variable $a
You can see the result under version < 8 and >= 8 here.
I came across with interesting problem,
I am using lumen on my windows localhost, the problem is while I write incorrect code or syntax error in my view/blade, lumen shows blank page instead of error. However, in controller or another page I am able to debug my code, It shows error.
Error debugging is open in php.ini.
APP_DEBUG=true in my project.
I have tried to fresh install, still same.
Edit app/Exceptions/Handler.php file , method render
e.g. make something like this:
public function render($request, Throwable $exception)
{
if (env('APP_DEBUG')) {
dd($exception);
}
return parent::render($request, $exception);
}
or you can grab it as it is instanceof Illuminate\View\ViewException
I am developing a laravel project but some part of my codes is returning an error of undefined request
Seems like i forgot something or ..
Here is a snip
Of my codes
the problem is with how you defined Request Parameter in your function, It should be like
public function insertrecord(Request $request) {}
Now you can proceed... Hope this helps..
I am trying to setup OData connection to MySQL database .. when I run the MySQLConnector.php , I am getting the above error.. can someone please direct me towards a solution.
The statement that gives the error is:
public function getEntityTypeName($entity)
{
return \Inflector::singularize($entity);
}
Following is the code in Inflector.php:
function singularize($word) {
$_this =& Inflector::getInstance();
if (isset($_this->_singularized[$word])) {
return $_this->_singularized[$word];
}
Please let me know if you would need any further information. Thanks in advance.
The short answer is: you need to update both of them. It looks like you have an older Inflector which is relying on deprecated PHP behaviour, and it's likely that your MySQLConnector.php is also old. If you don't update, you'll likely hit further problems.
In this case, PHP is complaining that you're using a static call to a method which is missing the "static" keyword. It's very likely that this message is a warning not an error, so it probably isn't causing whatever end problem you're experiencing. If you really want to address this message, you can just write static public function singularize($word) { instead, but like I said you will have more problems.
I'm having a strange problem in CakePHP where my AppExceptionRenderer is not being triggered for fatal and parse errors (E_ERROR and E_PARSE) when using PHP 5.2. The exact same code on my development machine (PHP 5.5) works fine.
Any ideas why?
I ended up tracking it down to what appears to be a bug in PHP 5.2 where a call to new SplFileInfo() strangely resets the fatal error information that normally exists inside error_get_last().
My fix was to tweak Cake's default App::shutdown() function by moving the _checkFatalError() call up above the Cache::write() calls.
So the result was this...
public static function shutdown() {
// For some weird reason on PHP 5.2 the SplFileInfo call made in Cache::write
// resets error_get_last() which means we can't trap fatal/parse errors.
// Small workaround is to check for errors *before* doing the caching thing
self::_checkFatalError();
if (self::$_cacheChange) {
Cache::write('file_map', array_filter(self::$_map), '_cake_core_');
}
if (self::$_objectCacheChange) {
Cache::write('object_map', self::$_objects, '_cake_core_');
}
// self::_checkFatalError();
}
Perhaps it may help someone else out there someday. :-)