buzzingpixel / ee-slim-bridge
Bridge for using Slim with ExpressionEngine
Requires
- php: ^8.1
- buzzingpixel/container: ^1.1
- slim/psr7: ^1.5
- slim/slim: ^4.9
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.31.0
- doctrine/coding-standard: ^9
- expressionengine/expressionengine: *
- phpstan/phpstan: ^1.4.2
- phpstan/phpstan-deprecation-rules: ^1.0.0
- phpstan/phpstan-strict-rules: ^1.1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
- symfony/var-dumper: ^5.3
README
This is probably only of interest to me, but you're welcome to use this project if you come across it and like it.
I really like working in Slim, with FastRoute, and PSR standard interfaces. To that end, I've created this extremely simple ExpressionEngine Extension that let's me do the front-end of EE sites in Slim and mostly ignore that EE is there in the background.
Here's how to use it:
Since you're wanting to use Slim and PHP and PSR interfaces, it is assumed that you already have composer setup and are loading the vendor autoload.
- In your craft project, run
composer require buzzingpixel/ee-slim-bridge
- Symlink or Docker mount or what ever you want to use
vendor/buzzingpixel/ee-slim-bridge/src/ExpressionEngine
tosystem/user/addons/slim_bridge
- Install the extension in the ExpressionEngine control panel
- Set up the configuration in your ExpressionEngine config file based on the examples in the [next section]((#config).
Config
In your config file, all configuration goes in an array key named 'slimBridge'
.
Three keys are available in the config file (See example):
enabled
If this is not set to (bool) true
, (string) 'yes'
, (string) 'y'
, (string) '1'
, or (int) 1
, then Slim Bridge will not serve the front-end via Slim. This could be theoretically useful if you want to do some logic or other to determine whether a request should be sent to Slim or let ExpressionEngine serve the request as normal.
containerInterface
Slim requires an implementation of \Psr\Container\ContainerInterface
and I've left this to project owners to provide. I've written what I think is a pretty good container implementation, and it is required as part of the project for internal use, so you could certainly configure and return an instance of that container.
appCreatedCallback
This is optional, but if you don't use it, then you won't have set any routes or middlewares and it will be useless to you. Once the app has been created, this callback will be run and the argument received will be the Slim App instance which you can use to set routes and middleware.