超薄框架无法正常工作
目前我正在使用ubuntu,我想在我的系统中安装PHP Slim framework
。超薄框架无法正常工作
我已经通过命令行安装了composer,并且还手动安装了Slim框架,然后我在slim文件夹中创建了一个index.php文件,并将下面的代码放在该文件中,并且当我尝试运行该文件时看不到。
<?php
require 'vendor/autoload.php';
$app = new SlimApp();
//slim application routes
$app->get('/', function ($request, $response, $args) {
$response->write("Welcome: This is AlphansoTech Tutorial Guide");
return $response;
});
$app->run()
?>
我试图拨打http://localhost/slim/index.php
,显示我空白屏幕。
我不知道第一次发生什么事我正在安装和使用苗条框架。
我试过下面的url来安装slim框架。
http://www.alphansotech.com/blogs/php-restful-api-framework-slim-tutorial/
https://www.slimframework.com/docs/tutorial/first-app.html
https://www.slimframework.com/docs/start/installation.html
如何安装或使用超薄框架上运行的API?
这是我使用作曲家安装的Slim代码。
的index.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
我访问文件的URL是http://localhost/slim/index.php/hello/suresh
的安装文件夹的名字 - slim
输出接收
Hello, suresh
文档从其次 - https://www.slimframework.com/
希望,它会给你一些提示,以解决您的问题。
给了我下面的错误。致命错误:require():无法打开所需的'vendor/autoload.php'(include_path ='。:/ usr/share/php') – samir
不要有任何'''vendor'''文件夹? – mi6crazyheart
no var/www/html/slim,我手动安装slim – samir
修身找不到供应商文件夹包含在您的composer.json所需的所有修身文件和其他依赖
您必须先安装
运行此赞扬所有依赖从你的项目目录
composer install
然后再次检查您的路线。如果您没有Composer,请首先访问getcomposer.org。
您是否检查安装指南? https://www.slimframework.com/docs/start/installation.html –