简单php Slim项目错误
我已经在安装了WAMP服务器的Windows 8.1上使用PHPStorm 8创建了一个简单的Slim微框架项目。默认情况下会设置所有WAMP服务器设置 我创建了一个名为简单php Slim项目错误,php,apache,wamp,wampserver,slim,Php,Apache,Wamp,Wampserver,Slim,我已经在安装了WAMP服务器的Windows 8.1上使用PHPStorm 8创建了一个简单的Slim微框架项目。默认情况下会设置所有WAMP服务器设置 我创建了一个名为pr1 我使用了“Init Composer…”,然后添加了一些依赖项,如slim/slim,slim/views,twig/twig 然后,我尝试创建一个简单的应用程序,就像主页上的一个给定示例: 我在我的项目文件夹中创建了名为index.php的文件 index.php 代码: 然后我创建了文件app.php 代码 在此之后
pr1
我使用了“Init Composer…”
,然后添加了一些依赖项,如slim/slim
,slim/views
,twig/twig
然后,我尝试创建一个简单的应用程序,就像主页上的一个给定示例:
index.php
的文件
index.phpapp.php
http://localhost:63342/pr1/wade
出现PHPStorm错误例如,您需要包括index.php
要摆脱index.php,请根据您的Web服务器使用.htaccess或类似的工具,因为Apachi不知道如何处理所有浏览器请求。因此,我创建了一个简单的.htaccess文件:
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
在此之后,我需要在WAMP设置中使用rewrite_模块
当我在浏览器中通过资源管理器打开project时,它可以完美地与project配合使用
在此之后,我将服务器设置为:
这使我能够通过PHPStorm预览所有更改我在项目的根目录中创建了一个.htaccess文件,现在它可以工作了。
require 'vendor/autoload.php';
$app = new \Slim\Slim();
$app->get('/:name', function ($name) {
echo "Hello, $name";
});
$app->run();
RewriteEngine On
# Some hosts may require you to use the `RewriteBase` directive.
# If you need to use the `RewriteBase` directive, it should be the
# absolute physical path to the directory that contains this htaccess file.
#
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]