Hello World from new Bundle

Membuat Hello World di bundle baru Symfony2

Baca yang sebelumnya tentang create bundle disini :

Symfony Bundle System (link)

dari artikel di atas kan sekaran kita memiliki bundle baru (fresh) yang bernama:


nah sekarang kita mau buat hello world disini (bundle ini)

Buat Controller baru di bundle baru tersebut (HoiWorldController.php) :


Isi dari HoiWorldController.php :

namespace Acme\TestBundle\Controller;

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

class HoiWorldController extends Controller {

* @Route(“/hoi/{msg}”)
public function greatingAction($msg)

$html = $this->container
array(‘msg’ => $msg)

return new Response($html);

* @Route(“/hoi2/{msg}”)
public function greating2Action($msg)

return $this->render(‘AcmeTestBundle:Hoi:hoi.html.twig’, array(‘msg’ => $msg) );


buat template buat view nya :



{% extends ‘base.html.twig’ %}

{% block body %}
<h1>From Acme: {{msg}}</h1>
{% endblock %}

nah sekarang bisa akses dan


2 thoughts on “Hello World from new Bundle

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s