我是symfony框架的初学者,我想运行我的功能
在BlogController中创建
<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class BlogController extends Controller
{
/**
* @Route("/blog")
*/
public function showAction()
{
echo "hello friend";
}
}
?>
C:\xampp\htdocs\mysymfony\src\AppBundle\Controller
mysymfony是项目名称。
这是我的routing.yml
app:
resource: "@AppBundle/Controller/"
type: annotation
当我点击URL时:
http:// localhost / mysymfony / blog
我得到这个错误
**
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8
**
我不知道如何运行BLOG函数的URL结构。请解决此问题
这很可能是因为您在根目录中运行了url。
使用Controller,您需要http://localhost/mysymfony/web/app_dev.php/blog
在开发环境或http://localhost/mysymfony/web/app.php/blog
生产环境中运行。
或将您的Apache配置为直接运行到web/
。您可以在这里找到该指南。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句