Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit 70e2fdc

Browse files
committed
feature #728 Added a new AppBundle to comply with Symfony Best Practices (javiereguiluz)
This PR was squashed before being merged into the 3.0-dev branch (closes #728). Discussion ---------- Added a new AppBundle to comply with Symfony Best Practices | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #671 | License | MIT | Doc PR | - Symfony Best Practices recommend to start developing your applications with a single AppBundle bundle. This PR allows to include that AppBundle in the Symfony Standard Edition, to make it easier for developers. I used the same skeleton as for the `generate:bundle` command, but I thought that it would be better to simplify it and remove the `$name` route parameter and use just a static template without parameters. Commits ------- 45da0d0 Added a new AppBundle to comply with Symfony Best Practices
1 parent afd4cd4 commit 70e2fdc

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

app/AppKernel.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function registerBundles()
1616
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
1717
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
1818
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
19+
new AppBundle\AppBundle(),
1920
);
2021

2122
if (in_array($this->getEnvironment(), array('dev', 'test'))) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% extends 'base.html.twig' %}
2+
3+
{% block body %}
4+
Homepage.
5+
{% endblock %}

app/config/routing.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
app:
2+
resource: @AppBundle/Controller/
3+
type: annotation

src/AppBundle/AppBundle.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace AppBundle;
4+
5+
use Symfony\Component\HttpKernel\Bundle\Bundle;
6+
7+
class AppBundle extends Bundle
8+
{
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace AppBundle\Controller;
4+
5+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7+
8+
class DefaultController extends Controller
9+
{
10+
/**
11+
* @Route("/", name="homepage")
12+
*/
13+
public function indexAction()
14+
{
15+
return $this->render('default/index.html.twig');
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace AppBundle\Tests\Controller;
4+
5+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6+
7+
class DefaultControllerTest extends WebTestCase
8+
{
9+
public function testIndex()
10+
{
11+
$client = static::createClient();
12+
13+
$crawler = $client->request('GET', '/');
14+
15+
$this->assertTrue($crawler->filter('html:contains("Homepage")')->count() > 0);
16+
}
17+
}

0 commit comments

Comments
 (0)