如何运行symfony项目


How to run the symfony project

我是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是项目名。

my 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
* *

我不知道URL的结构如何运行博客功能。请解决这个问题

这很可能是因为您在根目录下运行url。

对于控制器,您需要在开发环境中运行http://localhost/mysymfony/web/app_dev.php/blog,在生产环境中运行http://localhost/mysymfony/web/app.php/blog

或者配置Apache直接运行到web/