Open nibl opened 1 year ago
It seems like an issue with .php extension passing arguments. If you are using PHP-FPM to use TCP please try below
Nginx server conf
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^.+.php { fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+?.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; }
Also, add the base path in ui.php
'basePath' => '/ui.php',
The complete example
// file: webroot/index.php namespace Tqdev\PhpCrudUi { // Report simple running errors error_reporting(E_ERROR | E_PARSE);
use Tqdev\PhpCrudApi\RequestFactory;
use Tqdev\PhpCrudApi\ResponseUtils;
use Tqdev\PhpCrudUi\Config;
use Tqdev\PhpCrudUi\Ui;
$config = new Config([
'api' => [
'driver' => 'mysql',
'address' => 'localhost',
'port' => '3306',
'username' => 'php-crud-api',
'password' => 'php-crud-api',
'database' => 'php-crud-api',
],
'templatePath' => '../templates',
'basePath' => '/ui.php',
]);
$request = RequestFactory::fromGlobals();
$ui = new Ui($config);
$response = $ui->handle($request);
ResponseUtils::output($response);
}
ui.php is in the document root and shows this screen with links to "home", and the two tables called "posts" and "users":
But clicking the posts link to /posts/list gives a 404 error. Same for the users link. I cannot find any errors in the logs. Any ideas what the cause might be?
Running Ubuntu 22.04 with latest ui.php, nginx 1.18.0, PHP 8.12, Mysql 8.0