slimphp / Slim-Skeleton

Slim Framework 4 Skeleton Application
http://www.slimframework.com
MIT License
1.59k stars 479 forks source link

Question on app initialization #52

Closed codedokode closed 7 years ago

codedokode commented 7 years ago

Hello.

I remember in Slim 2 we used to write settings and routes inside index.php and now they have moved into separate files like settings.php, routes.php. Is the current approach adopted from some other framework?

I see some disadvantages with it:

I can suggest an alternative approach: we could make a bootstrap file (initializing autoloading, App class, DI container) and index.php with middleware and routes. So the CLI command could just require a bootstrap file and get fully configured App object.

What do you think about it?

tflight commented 7 years ago

This Slim-Skeleton project does have settings, routes, middleware, and DI split out into separate files. As a skeleton project, it is merely an example of how you could setup your app, not necessarily what will make the most sense for your own application. It also includes tools like Monolog and PHP-View which many people might not use, but similarly are included because it is an example project.

The base Slim 3 project uses a single index.php file like how you describe and sounds more applicable to what you are looking for.

akrabat commented 7 years ago

There's also my empty slim skeleton which works with a single index.php.