php - Organise custom classes -


i'm trying learn basics of slim 3 , have difficulties trying figure out proper way organise custom code, esp. custom classes. instance, want create custom error handler:

<?php namespace app\handlers; // [...] final class error extends \slim\handlers\error {     // [...] } 

... documentation i've checked hasn't revealed under path save class definition or how configure framework can found in index.php entry point:

<?php require __dir__ . '/../vendor/autoload.php'; // [...] $app = new \slim\app(['settings' => ['displayerrordetails' => true]]); $container = $app->getcontainer(); $container['errorhandler'] = function ($c) {     return new app\handlers\error($c['logger']); }; 

fatal error: class 'app\handlers\error' not found

i'd appreciate hint.

you're problem not related framework @ all.

slim doesn't tell keep custom code because it's matter of free choice.

your error:

fatal error: class 'app\handlers\error' not found

is not generated slim, php itself. need add autoloader code let php know find appropriate classes.

i can see utilize composer, therefore it's best option configure composer.json create autoloader code.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -