is_404
I guess :D
the condition
\App::route()->get()->where( 'query_var', 's' )->handle( $handler );
Only matches default query vars defined in WP_QUERY right?
Something like this did not work for me for "non WP Urls".
https//example.com/page?foo='bar'
::routeUrl()
will work though, since reverse construction is not supported in FastRoute
@atanas-dev FastRoute is still maintained and in fact 2.0 is soon to be released. Nevertheless 1.3 is stable and feature complete. Lumen, Slim and other still use it.
I could not resist myself and got this done. I have a working version locally which works like this now: ( note that this is basically a complete rewrite of the router and condition factory. )
I assume performance will be a lot higher for sites with many routes but I dont have the time to benchmark things right now and Im also not that experienced in setting up proper benchmarking.
Ofc I dont have any expectations of this being merged ever ( required php 7.3 ) but Ill share you the repo if you want when Im done, maybe you ll find some ideas for WPEmerge aswell.
Right now I have a suggestion for you tho, maybe you overlooked this at first.
Whoops has an option to open files directly in the editor of your choice.
Its as simple as doing this.
$pretty_page_handler->setEditor('phpstorm');
Might be a nice addition, the value would then come from the user config of course
myapp_get_index_404_message()
but i'm struggling on how to detect a page that is not going through a page template, a page or anything from WP (since it's built by the controller...). anything i've tested so far works (is_page()
, is_page_template()
, is_archive()
, etc). any idea on how to intercept that? thanks :)
get_header()
@atanas-dev hey atanas, just wanted to let you know a possible bug I found while working on my own version of wpemerge. Right now when you render a view its almost impossible to catch expection while rendering the php file. Because the __toString()
methods gets called recursivly output buffering also gets turned on end off everytime. This results in all the html before the error being print to the screen while everythings after the exception doesnt.
IMO the output buffering should be one level above the the rendering logic inside the toResponse()
method on the PhpView
class.
This way you can properly render exceptions without the view output. Maybe this is due to an edge case in my version but Im pretty certain I have not modified anything relevent inside the view related classes.
Anyway this is what fixed it form me.
// Inside PhpView
public function toResponse() : ResponseInterface {
ob_start();
try {
$this->toString();
} catch (\Throwable $exception) {
ob_end_clean();
throw new ViewException();
}
$content = ob_get_clean();
return ( new Response( $content ) )->setType( 'text/html' );
}
The output is the following with the default WP error page:
"Foobar
Fatal error: Uncaught Error: Call to undefined function non_existing_function() in /Users/calvinalkan/valet/booking/wp-content/plugins/test-plugin/view.php:10 Stack trace: #0 /Users/calvinalkan/valet/booking/wp-content/plugins/snicco-bookings-"
It also makes sense why this happens:
Inside the PhpView:
public function toString() {
if ( empty( $this->getName() ) ) {
throw new ViewException( 'View must have a name.' );
}
if ( empty( $this->getFilepath() ) ) {
throw new ViewException( 'View must have a filepath.' );
}
$this->engine->pushLayoutContent( $this );
if ( $this->getLayout() !== null ) {
// ERROR HAPPENS HERE
return $this->getLayout()->toString();
}
return $this->engine->getLayoutContent();
}
Hey. I am trying to get started with WP Emerge. I've been following 0 to 100 Setup.
However it states I am supposed to get the error:
Fatal error: Uncaught Error: Class '\App\Controllers\Web\HomeController' not found
But instead I receive:
There has been a critical error on this website.
I assumed it was just because maybe the newer version has a different error but as I kept following the steps where it is supposed to resolve the error, it did not. Everything was fine until I reached that stage and double checked that I pasted in the code correctly in the .php and .json files.
Does anyone have any pointers on what could be happening or links to any resources? I can't find any resources online on WP Emerge besides this site itself.
Warning: Use of undefined constant WPEMERGE_APPLICATION_FILESYSTEM_KEY - assumed 'WPEMERGE_APPLICATION_FILESYSTEM_KEY' (this will throw an Error in a future version of PHP) in /var/www/vhosts/rechtsanwalt.com/dev.rechtsanwalt.com/wp-content/plugins/racom-directory/app/src/WordPress/AssetsServiceProvider.php on line 29
Fatal error: Uncaught Pimple\Exception\UnknownIdentifierException: Identifier "WPEMERGE_APPLICATION_FILESYSTEM_KEY" is not defined. in /wp-content/plugins/racom-directory/vendor/pimple/pimple/src/Pimple/Container.php:101 Stack trace: #0 /wp-content/plugins/racom-directory/app/src/WordPress/AssetsServiceProvider.php(29): Pimple\Container->offsetGet() #1 //wp-content/plugins/racom-directory/vendor/htmlburger/wpemerge/src/Application/LoadsServiceProvidersTrait.php(107): RacomDirectory\WordPress\AssetsServiceProvider->bootstrap() #2 /var/www/vhosts/rechtsanwalt.com/dev.rechtsanwalt.com/wp-content/plugins/racom-directory/vendor/htmlburger/wpemerge/src/Application/LoadsServiceProvidersTrait.php(82): WPEmerge\Application\Application->bootstrapServiceProviders() #3 /var/www/vhosts/rechtsanwalt.com/dev.rechtsanwalt.com/wp-content/plugins/racom-directory/vendor/htmlburger/wpem in /var/www/vhosts/rechtsanwalt.com/dev.rechtsanwalt.com/wp-content/plugins/racom-directory/vendor/pimple/pimple/src/Pimple/Container.php on line 101