I want to start using SLIM3 but its alongside an existing application, I like to introduce slim as an api layer, so I would either like to put slim in a sub directory or use and alternative file to index.php to load my slim application and then use the router to handle /api call’s. I’d like to use https://github.com/slimphp/Slim-Skeleton so I can use the router etc.
Hope that makes sesnse.
Advice on setting that up would be much appreciated
The correct approach might depend on what your desired outcome is. Will Slim eventually handle more than just the API, or will it just be for the API? If just the API, you could put an
index.php for Slim in a
api subdirectory and keep the source files out of
public. http://example.com/api/ An alternative might be to build it as a subdomain http://api.example.com/
If going the subdirectory route, depending on how your other app is setup you would need to adjust the index.php from the Skeleton to point to things another directory up.
// require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../../vendor/autoload.php';
Depending which webserver you are using you may need to make a few other tweaks. I recall people using Nginx needed to make a few other tweaks to get Slim working in a subdirectory.
The app is to support a Jquery Mobile app so I would see it there to primarily as an api so the sub-directory approach would work. I use it with apache, and am using some .htaccess files with my current setup. I also use the php server for my debug setup so I use php server from my root directory. I will give it a go with slim in the api sub-dir. and see how it goes.
Thanks for the response