Reputation: 28
When I run the project on my localhost the routes work perfectly but when I export to shared hosting it keeps giving {"data": "Resource not found", "code":404} according to the 404 configurations in the Route/index.php
I've hosted a previous project using this framework and it still works to this moment, but I don't know what I'm doing wrong for this particular project. I've crossed checked the previous project config with this one and there's no difference.
This is the content of my .env file
APP_NAME=LEAF_API
APP_ENV=local
APP_KEY=base64:AUAyDriQD1kFdIbwTHlnCm2pYn+qxDBa55SFwB9PUzg=
APP_DOWN=false
APP_DEBUG=true
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=9jafood
DB_USERNAME=root
DB_PASSWORD=
DB_CHARSET=utf8
DB_COLLATION=utf8_unicode_ci
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
PROD_SERVER=hello
PROD_PORT=22
PROD_USER=leaf
APPLICATION_DIR=leaf
APPLICATION_PATH=leaf
This is my .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
This the index file that the .htaccess file rewrites to
<?PHP
require_once __DIR__ . '/vendor/autoload.php';
\Dotenv\Dotenv::create(__DIR__)->load();
require __DIR__ . "/Config/bootstrap.php";
require __DIR__ . "/Config/functions.php";
Leaf\View::attach(\Leaf\Blade::class);
$app = new Leaf\App(AppConfig());
$app->evadeCors(false);
require __DIR__ . "/App/Routes/index.php";
$app->run();
This is my index.php file located in the Route folder
<?php
/**@var Leaf\App $app */
$app->set404(function () {
json("Resource not found", 404, true);
});
$app->setErrorHandler(function ($e = null) use($app) {
if ($e) {
if ($app->config("log.enabled")) {
$app->logger()->error($e);
}
}
json("An error occured, our team has been notified", 500, true);
});
$app->setNamespace("\App\Controllers");
require __DIR__ . "/_route.php";
This is my route.php
<?php
$app->group("/merchant", function () use ($app) {
$app->post("/", "VendorsController@index");
$app->get("/delivery/{id}", "VendorsController@cost");
$app->get("/category/{id}", "CategoriesController@index");
});
$app->group("/meal", function () use ($app) {
$app->get("/", "MealsController@index");
$app->post("/search", "MealsController@search");
$app->post("/search/location", "MealsController@searchBasedOnLocation");
});
Upvotes: 0
Views: 502
Reputation: 31
this might be really late considering the date, but I just noticed you are requiring a _route.php
file but your file name looks like route.php
.
Also you can post your questions on the leaf forum on GitHub as well so they can be resolved quickly.
Upvotes: 1