http://docs.slimframework.com/start/get-started/#hello-这个世界留下了许多悬而未决的问题,我想知道他们为什么解释得这么糟糕?还是我错过了什么?
首先,我如何运行应用程序的测试?
我打开
http://localhost/myapp/hello/dirk
404 FOF错误
在此服务器上找不到请求的URL/myapp/hello/dirk。
冷却
设置非常简单
这是我的index.php
<?php
require 'vendor/autoload.php';
require 'Slim/Slim.php';
'Slim'Slim::registerAutoloader();
$app = new 'Slim'Slim();
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
$app->run();
?>
编辑
斯利姆的"入门"显然是不完整的。
如果你,偶然点击url重写章节,你会阅读
我强烈建议您使用支持URL的web服务器重写;这将让你享受干净,人性化的网址您的Slim应用程序。
好吧,不,这是不鼓励的,只是如果你不这样做,它根本不起作用(你好世界)。看看我的答案。
因此在以下内容之后:
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-slim-framework-on-ubuntu-14-04
祝贺你,我希望写《开始》的人(官方的苗条2号)会因为懒惰而撞到门上。
因此,您必须在index.php 的级别上添加.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
http://docs.slimframework.com/routing/rewrite/
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
require 'vendor/autoload.php';
require 'vendor/slim/slim/Slim/Slim.php';
'Slim'Slim::registerAutoloader();
$app = new 'Slim'Slim();
$app->get('/hello/:name', function ($name) {
echo "Hello, $name";
});
$app->get('/', function () {
echo "Thanks for not including essential info to the getting started";
});
$app->run();
?>