I have a PHP application that is using Slim framework for APIs. Everything is working fine on localhost...however... not on the VPS..I am using Digital Ocean.
Here is my project structure.... Just wanted to ensure whether it is right.
ROOT DIRECTORY - app
-- admin - index.php (Main App Homepage) - .htaccess
MAIN ISSUE:
On running the app... say login page...it makes a request to the Slim ...the api responds back with the json...but it shows in the browser rather than showing the html formatted response.
Not sure what is missing. .htaccess for Slim
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ %{ENV:BASE}index.php [QSA,L]
.htaccess for main app
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
</IfModule>
Did you change the content-type to application/json ? Check this , Slim has a simple way to return a json, this way :
$data = array('name' => 'Bob', 'age' => 40);
$newResponse = $oldResponse->withJson($data);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.