I need some help to use Slim Framework. Indeed, I'm a beginner in PHP and I would like to migrate my API using Slim Framework in order to have a clean code. I successed to run Slim Hello Word app on my WAMP server locally, but when I deploy it on my OVH server shared, I have a blank page on route [root]/myproject/hello/test.
The question has already asked but the problem was not exactly the same.
For information I had a 500 internal error locally which was resolved when I've activated rewrite_module on my WAMP server. I have a SSH access to OVH server but composer is not installed. It seems that mod_rewrite is enabled. WAMP and OVH server use PHP 5.5
This is my folder directory:
Project/
src/
public/
.htaccess
index.php
vendor/
autoload.php
slim/
slim/
Slim/
App.php
...
composer.json
composer.lock
This is my .htaccess file
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
And my index.php
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '../vendor/autoload.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
Any ideas to resolve it? Thanks.
try to use this .htaccess config
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
#RewriteBase /path/to/app
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
Also install monolog https://github.com/Flynsarmy/Slim-Monolog