I've started using Symfony 2 just a couple of days ago. I'm currently working on a tool for market research purposes. This tool is supposed to consist of multiple modules, with each being a bundle in the Symfony project. I could of course just make these modules all in a single bundle, but the idea is to keep the code as maintainable as possible in order to ease the process of fixing bugs or improving and adding new modules.
So basically my folder structure is like this:
AppBundle -> Controller -> DefaultController: this is used upon initial loading of the site. It doesn't do anything more than return a rendered Twig Template which is lying in my frontend bundle.
company | |__> AdministrationBundle: this is supposed to be the management backend where modules can be configured, users can be added or edited and so on.
|
|__> FrontendBundle: this is the core bundle so to say. It contains the basic Twig template, which is used to render the general site structure and navigation
|
|__> Module_1_Bundle: that's the first module which is supposed to being navigated to basic Twig template generated in the frontend controller
|
|__> Module_2_Bundle: same as module 1.
Frontend is rendered correctly, no issues there. But as soon as I try and navigate to either Module 1 or Module 2 (I haven't started with the Administration Bundle yet), all I'm getting is
Oops! An Error Occurred The server returned a "500 Internal Server Error". Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.
There's nothing in the Apache Error logs, nor in the Symfony logs and I have literally not the slightest idea what's going on there. I have configured the initial routes to the modules in app/config/routing.yml like this:
app:
resource: @AppBundle/Controller
type: annotation
company_frontend:
resource: "@CompanyFrontendBundle/Resources/config/routing.yml"
company_backend:
resource: "@CompanyAdministrationBundle/Resources/config/routing.yml"
company_module_1:
resource: "@CompanyModule_1_Bundle/Resources/config/routing.yml"
company_module_2:
resource: "@CompanyModule_2_Bundle/Resources/config/routing.yml"
Each routing.yml then contains the routings needed for the according module, which is basically like this (e.g. company/Module_1_Bundle/Resources/config/routing.yml):
company_module_1:
path: /module1
defaults: { _controller: CompanyModule_1_Bundle:Module1:index }
with the according Module1Controller being this:
<?php
namespace Company\Module_1_Bundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
class Module1Controller extends Controller
{
public function indexAction()
{
return $this->render('CompanyModule_1_Bundle:Default:index.html.twig', array("headerText" => "some Module 1 heading"));
}
}
I'm really scratching my head as to why it doesn't work. I really hope you guys can help me out. :)
Alright, you may officially call me an idiot. :) After revamping the code, I decided to clean up my server a bit. Part of that was renaming the directory the project was in and adjust the apache2 vhost config. What I didn't adjust though was the deployment settings in PHPStorm though, which means that all the changes I made still went to the old folder (which PHPStorm created again), hence I never saw any changes, since the files in the recently renamed folder remained untouched. Damn. It's all sorted and working now. Thanks again. :)