The welcome page for symfony2 does not appear.

Asked 1 years ago, Updated 1 years ago, 100 views

I am building the environment based on the following tutorial on symfony2.
I am troubled that the welcome page is not displayed.

http://docs.symfony.gr.jp/symfony2/quick_tour/the_big_picture.html#quick-tour-big-picture-built-in-server

[Error Contents]

No route found for "GET /" 404 Not Found - NotFoundHttpException 1
linkedException:ResourceNotFoundException <

ERROR-Uncaught PHP Exception
Symphony\Component\HttpKernel\Exception\NotFoundHttpException: "No
route found for "GET /" at
C:\xampp\htdocs\project\app\cache\dev\classes.phpline2059

I installed the necessary files such as components, but
Could someone please tell me if there is anything else I have overlooked?

Thank you for your cooperation.

php symfony2

2022-09-30 12:03

1 Answers

Assume Symphony 2.7 LTS. Do you want to go to http://localhost:8000/app/example and see the Homepage string?

Although not reflected in the Japanese documentation, Symfony 2.7 LTS now recommends setting up projects with the Symphony Installer.

How to set up the Symphony Installer is displayed by clicking the blue text "install the Symphony Installer" on the download page.

Linux and Mac OS X run the following commands:When I introduced my Mac OS X, I didn't use sudo.

$sudocurl-LsS http://symfony.com/installer-o/usr/local/bin/symfony
$ sudo chmod a+x/usr/local/bin/symfony

For Windows:

 c:\>php-r "readfile('http://symfony.com/installer');">symfony

The controller used to view /app/example is src/AppBundle/Controller/DefaultController.php, and the template is app/Resources/views/default/index.html.twig.

An example of controller practice is the code that appears when you access /app/foo.For exercises that do not require HTML escape considerations, it is useful to use a Response object as a return value.

//src/AppBundle/Controller/DefaultController.php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symphony\Bundle\FrameworkBundle\Controller\Controller;
use Symphony\Component\HttpFoundation\Response;

class DefaultController extensions Controller
{
    /**
     * @Route("/app/{name}", name="homepage_hello")
     */
    public function helloAction($name)
    {
        return new Response ($name. 'Hello, Mr./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms./Ms.
    }
}

If you want to return JSON, return the JsonResponse object.

use Symphony\Component\HttpFoundation\JsonResponse;

public function someAction()
{
    return new JsonResponse(["key"=>"value"]);
}


2022-09-30 12:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.