I think you misunderstood what Symfony2 offers you. I'll try to explain some of them for your use case.
What I understood
You want to create an admin panel on your website. It's a common case.
What to do
You should create a bundle for this whole content. Like AdminBundle
Step by step
Let's look at a Symfony2 directory structure. Here's an excerpt.
project/
app/
config/
config.yml
parameters.yml
cache/
AppKernel.php
src/
Acme/
DemoBundle/
Controller/
Resources/
config/
public/
views/
AcmeDemoBundle.php
vendor/
symfony/
autoload.php
web/
.htaccess
app.php
app_dev.php
The whole project
directory is your Application
It can contain a lot of different websites if needed or it can just be a single one.
Your application logic (website in this case) should be in the src
folder, delegated as Bundle
's
You can read more about what is a bundle or should everything be a bundle
Front End Logic
So, in your case you may have a FrontBundle
which contains the frontend logic, like this
project/
src/
Acme/
FrontBundle/
Controller/
IndexController.php
Resources/
views/
Index/
pages.html.twig
layout.html.twig
Acme\FrontBundle\Controller\IndexController
<?php
namespace Acme\FrontBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
class IndexController extends Controller
{
/**
* @Route("/pages")
* @Template
*/
public function pagesAction()
{
$em = $this->getDoctrine()->getManager();
// Note that we fetch from AdminBundle
$pages = $em->getRepository('AcmeAdminBundle:Page')->findAll();
return array('pages' => $pages);
}
}
This controller is matched on http://example.com/pages
This would fetch the pages of your AdminBundle entity.
Admin Panel
Now that you want an admin panel, you can create another bundle which contains only this logic.
This bundle has its own controllers and views which can be used by the whole application
project/
src/
Acme/
FrontBundle/
AdminBundle/
Controller/
PagesController.php
Entity/
Page.php
Resources/
views/
Pages/
add.html.twig
edit.html.twig
layout.html.twig
Services/
AdminAuth/
AdminCore/
Services
Here's your logic classes where you want to add your some of your components.
Read more about Services
Entity
Read about doctrine entities
Controller
Acme\AdminBundle\Controller\PagesController
<?php
namespace Acme\AdminBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
/**
* @Route("/admin/pages")
*/
class PagesController extends Controller
{
/**
* @Route("/edit")
* @Template
*/
public function editAction()
{
// Edit
}
/**
* @Route("/add")
*/
public function addAction()
{
// Add
}
}
The edit action would match on http://example.com/admin/pages/edit
The add action would match on http://example.com/admin/pages/add
Further reading