Reputation: 8872
I have an existing website\application. I want to create a JSON API using lumen in a sub directory–something like /api/
.
How do you install lumen or laravel only in a sub directory of a website?
Upvotes: 1
Views: 2362
Reputation: 788
redirect request with ".htaccess" (if you cannot modify apache conf):
RewriteRule ^api/(.*)$ /api/public/$1 [L]
use a Group with a prefix in your app/Http/router.php to remove the subfolder:
$app->group(['prefix' => 'api'], function () use ($app) {
$app->get('/', function () use ($app) {
return $app->version();
});
});
Upvotes: 2
Reputation: 126
Try using Alias in your apache conf (virtualhost):
Alias /api /path/to/api/public
<Directory /path/to/api/public>
Allowoverride All
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
Also, because Lumen gets the wrong path when used from a sub directory you will need to change the following line in Lumens public/index.php:
from $app->run();
to $app->run($app->make('request'));
Upvotes: 1