Example
- Install symfony correctly as guided above.
- Start symfony server if you are not installed in www directory.
- Ensure http://localhost:8000 is working if symfony server is used.
- Now it is ready to play with simplest example.
- Add following code in a new file /src/AppBundle/Controller/MyController.php in symfony installation dir.
- Test the example by visiting http://localhost:8000/hello
- 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>'
);
}
}