symfony3 Getting started with symfony3 Simplest example in Symfony

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

  1. Install symfony correctly as guided above.
  2. Start symfony server if you are not installed in www directory.
  3. Ensure http://localhost:8000 is working if symfony server is used.
  4. Now it is ready to play with simplest example.
  5. Add following code in a new file /src/AppBundle/Controller/MyController.php in symfony installation dir.
  6. Test the example by visiting http://localhost:8000/hello
  7. That's all. Next: use twig to render the response.
<?php
// src/AppBundle/Controller/MyController.php

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;

class MyController
{
    /**
     * @Route("/hello")
     */
    public function myHelloAction()
    {
        return new Response(
            '<html><body>
                   I\'m the response for request <b>/hello</b>
             </body></html>'
        );
    }
}


Got any symfony3 Question?