大家好。我目前已经完成了我的第一个PHP web应用程序的开发,这是一个使用流行的PHP微框架构建的非常简单的应用程序-
Slim Framework 3
.
get
请求到不同的模板页面。我正在使用
slimphp/Twig-View
主要的
index.php
文件如下所示:
// Require composer autoloader
require __DIR__ . '/vendor/autoload.php';
// Application settings
$settings = require __DIR__ . '/app/settings.php';
// New Slim app instance
$app = new Slim\App( $settings );
// Add our dependencies to the container
require __DIR__ . '/app/dependencies.php';
// Require our route
require __DIR__ . '/app/routes.php';
// Run Slim
$app->run();
这个
routes.php
// Creating routes
// Psr-7 Request and Response interfaces
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
$app->group('/', function () {
$this->get('', function (Request $request, Response $response, $args) {
$vars = [
'page' => [
'title' => 'East End Ink',
'description' => 'Best apparel company in Austin'
],
];
return $this->view->render($response, 'home.twig', $vars);
});
$this->get('products', function (Request $request, Response $response, $args) {
$vars = [
'page' => [
'title' => 'East End Ink',
'description' => 'Best apparel company in Austin'
],
];
return $this->view->render($response, 'products.twig', $vars);
});
[...... cut out some repetition ....]
$this->get('services', function (Request $request, Response $response, $args) {
$vars = [
'page' => [
'title' => 'East End Ink',
'description' => 'Best apparel company in Austin'
],
];
return $this->view->render($response, 'services.twig', $vars);
});
});
整个应用程序的源代码是
HERE
这就是我在本地运行web应用程序的感觉:
20秒视频-
http://tinypic.com/r/n6c5g7/9
php -S localhost:8080
一次
localhost:8080
云道-
http://phpstack-115365-328618.cloudwaysapps.com/
FortRabbit公司-
https://custom-5yx3.frb.io/
当我尝试导航到此登台环境上任何其他页面的路由时,我遇到的错误如下:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.10 (Debian) Server at phpstack-115365-328618.cloudwaysapps.com Port 80
我认为它所做的只是在那里提供php文件,就像php在本地所做的那样,如果我在端口80处访问应用程序的路由而不运行
我在本地复制同一问题的17秒视频:
http://tinypic.com/r/28s6n87/9
现在的问题是:
我如何在CloudWays或FortRabbit这样的地方托管这个web应用程序。一般来说,我要做什么才能让它在那里运行?如果你够客气的话,我可以具体做些什么?
附笔。
该网站的源代码仍然是公开的,所以请随时查看它的
GitHub Repo
阅读文件。
P、 P.S。
我非常感谢你能提供的任何帮助。我是一个n00b和这个竞技场,当我像在其他领域一样成为一个更能干/更有经验的PHP开发人员时,我会偿还这笔钱。