Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error not captured #1074

Open
dennismarksbury opened this issue Oct 13, 2022 · 20 comments
Open

Runtime error not captured #1074

dennismarksbury opened this issue Oct 13, 2022 · 20 comments

Comments

@dennismarksbury
Copy link

dennismarksbury commented Oct 13, 2022

When I run the application, the code is failing, but there is no error that I can find. If I debug into the code, I am only able to go part way through the code and then the code appears to crash, without any notification.

I have pushed the test projects to the following GitHub: https://github.com/dennismarksbury/LaravelOnPeachPie

Code fails here:
Web1/index.php : Line 52

Environment:
Windows
Visual Studio Pro 2019

Peachpie.NET.Sdk/1.0.0-appv4909
Peachpie.AspNetCore.Web/1.0.24

Question: is there a "preferred" environment?

@jakubmisek
Copy link
Member

Thank you, it seems the ASP.NET Core Middleware does not propagate the error to the request pipeline (I'll try to fix that)

Anyways; there are errors and notices in the console and the debug Output pane:

PHP (Notice): Script 'C:\Users\jmise\Projects\LaravelOnPeachPie\Web1\Web1.Server\vendor\composer/../symfony/http-kernel/HttpKernelInterface.php' inclusion failed. Cause: Script file 'C:\Users\jmise\Projects\LaravelOnPeachPie\Web1\Web1.Server\vendor\composer/../symfony/http-kernel/HttpKernelInterface.php' not found. Search paths: include_path is '.', working directory is 'vendor/composer' 

Exception thrown: 'Pchp.Library.Spl.Error' in Peachpie.Runtime.dll

PHP (E_ERROR): Error: Class 'Symfony\Component\HttpKernel\HttpKernelInterface' not found in C:\Users\jmise\Projects\LaravelOnPeachPie\Web1\Web1\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(29,0)
Stack trace:
#0 C:\Users\jmise\Projects\LaravelOnPeachPie\Web1\Web1\vendor\composer\ClassLoader.php(428,12): {main}
#1 : ClassLoader->loadClass($class)
#2 : {main}

@jakubmisek
Copy link
Member

Peachpie.NET.Sdk/1.0.0-appv4909
Peachpie.AspNetCore.Web/1.0.24

both versions should be the same - otherwise you have a NuGet warning when building the project

@jakubmisek
Copy link
Member

Sadly Laravel starts the response, so the developer exception page (UseDeveloperExceptionPage()) is not able to output its own content anymore.

The iis express log contains all the PHP notices and errors tho. You can also handle the exception in Visual Studio or any other IDE while debugging.

image

What we can do, is implement a "default" PHP exception handler and output the exception to the response by ourselves. But usually, it's all handled by ASP.NET already.

@dennismarksbury
Copy link
Author

dennismarksbury commented Oct 25, 2022 via email

@dennismarksbury
Copy link
Author

dennismarksbury commented Oct 25, 2022 via email

@jakubmisek
Copy link
Member

So can i use the following? Peachpie.NET.Sdk/1.0.0-appv4909 Peachpie.AspNetCore.Web/1.0.0-appv4909

the latest official release is 1.1.2 or the latest nightly build [1.2.0-r14735](https://www.nuget.org/packages/Peachpie.NET.Sdk/1.2.0-r14735)

https://www.nuget.org/packages/peachpie.net.sdk

@jakubmisek
Copy link
Member

So this is interesting... it says that the HttpKernelInterface is not found... but I don't understand why it cannot find it... it is in the project, exactly where I would expect it to be. What would prevent this interface from being found?

It is probably caused by the first error:

PHP (Notice): Script 'C:\Users\jmise\Projects\LaravelOnPeachPie\Web1\Web1.Server\vendor\composer/../symfony/http-kernel/HttpKernelInterface.php' inclusion failed. Cause: Script file 'C:\Users\jmise\Projects\LaravelOnPeachPie\Web1\Web1.Server\vendor\composer/../symfony/http-kernel/HttpKernelInterface.php' not found. Search paths: include_path is '.', working directory is 'vendor/composer' 

isn't this particular script file excluded from compilation?

@dennismarksbury
Copy link
Author

dennismarksbury commented Oct 25, 2022 via email

@dennismarksbury
Copy link
Author

My image didn't come through.... here's the line in the .msbuildproj file

<Compile Include="vendor\symfony\Component\HttpKernel\HttpKernelInterface.php" />

So I would assume it is compiling it.

@jakubmisek
Copy link
Member

jakubmisek commented Oct 25, 2022

I see!

Yep, this might be a really important bug.

Edit: ok not a bug :/

@jakubmisek
Copy link
Member

jakubmisek commented Oct 25, 2022

it is looking for:
vendor\symfony\http-kernel\HttpKernelInterface.php
not:
vendor\symfony\Component\http-kernel\HttpKernelInterface.php


this file is indeed not compiled

@dennismarksbury
Copy link
Author

dennismarksbury commented Oct 25, 2022 via email

@jakubmisek
Copy link
Member

Question... so when the PHP classes are loaded, is it loading by namespace or by physical path based on namespace?

those are a few separate steps

When the class that is not declared is used, PHP calls a class loader (in this case composer with its set of rules, usually based on the so-called PSR-4)

Then the file containing the class declaration must be included -> composer does it by parsing the class namespace to construct the expected file path, it checks that the file exists on the file system, and then it includes it. If this fails, PHP throws a warning, but continues.

With PeachPie, the file may exist on disk, but if it's not compiled, the inclusion fails.

Finally, PHP actually uses the class (that's expected to be loaded now), which may fail with fatal error.

@dennismarksbury
Copy link
Author

dennismarksbury commented Oct 25, 2022 via email

@jakubmisek
Copy link
Member

@dennismarksbury it's not about moving the files ... they are there but explicitly excluded in your .msbuild

@dennismarksbury
Copy link
Author

dennismarksbury commented Oct 25, 2022

I deleted all folders that were explicitly excluded from the build in the \vendor\symphony folder...

Removed the following line from the .msbuildproject file

<None Remove="vendor\symfony\**" />

Ensure that the compile include IS still there:

<Compile Include="vendor\symfony\Component\HttpKernel\HttpKernelInterface.php" />

I still get the same error.

@jakubmisek
Copy link
Member

As mentioned earlier, you're looking at wrong path:

vendor\symfony\http-kernel\HttpKernelInterface.php
not:
vendor\symfony\Component\http-kernel\HttpKernelInterface.php

That's the problem.

Also everything is in the application log, I guess there is still the following:
PHP (Notice): Script 'C:\Users\jmise\Projects\LaravelOnPeachPie\Web1\Web1.Server\vendor\composer/../symfony/http-kernel/HttpKernelInterface.php' inclusion failed.

(not *\Component* in there)

@dennismarksbury
Copy link
Author

Ok, i've figured it out! all these classes are defined in autoload_static.php, which points to incorrect directories. I am working to clean this up.

@dennismarksbury
Copy link
Author

dennismarksbury commented Apr 25, 2023 via email

@jakubmisek
Copy link
Member

Hi @dennismarksbury ,

Thanks for the details. Laravel does a lot of class aliasing, and global functions like tap() are usually in helpers:

vendor\laravel\framework\src\Illuminate\Support\helpers.php

Although they are defined conditionally (inside if statement), so the compiler cannot call them directly - there will be an overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants