# Slim alongside existing App

**URL:** <https://discourse.slimframework.com/t/slim-alongside-existing-app/1412>\
**Category:** Questions\
**Created:** [April 20, 2017, 10:36am UTC](https://discourse.slimframework.com/t/slim-alongside-existing-app/1412 "2017-04-20T10:36:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![grantTF](https://avatars.discourse-cdn.com/v4/letter/g/5fc32e/32.png) [@grantTF](https://discourse.slimframework.com/u/grantTF)\
**Post date:** [April 20, 2017, 10:36am UTC](https://discourse.slimframework.com/t/slim-alongside-existing-app/1412/1 "2017-04-20T10:36:40Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![tflight](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.slimframework.com/tflight/32/1205_2.png) [@tflight](https://discourse.slimframework.com/u/tflight)\
**Post date:** [April 20, 2017, 12:16pm UTC](https://discourse.slimframework.com/t/slim-alongside-existing-app/1412/2 "2017-04-20T12:16:21Z")

</div>

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/](http://example.com/api/) An alternative might be to build it as a subdomain [http://api.example.com/](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](https://github.com/slimphp/Slim-Skeleton/blob/master/public/index.php#L12) to point to things another directory up.

```php
// 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.

---

<div class="post-metadata">

**Author:** ![grantTF](https://avatars.discourse-cdn.com/v4/letter/g/5fc32e/32.png) [@grantTF](https://discourse.slimframework.com/u/grantTF)\
**Post date:** [April 20, 2017, 1:38pm UTC](https://discourse.slimframework.com/t/slim-alongside-existing-app/1412/3 "2017-04-20T13:38:39Z")

</div>

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
