-2

I'm very new to symfony, but I'm sure it will help me to develop faster.

So here are my basic problem. I want to develop a application, that can be used by multiple clients. They will all have its own url. Something like this:

http://example.com/customer1
http://example.com/customer2

I see, that this is very easily done by editing the routing.yml - thats very cool stuff

app:
    resource: "@AppBundle/Controller/"
    prefix:   /{customer}/
    type:     annotation

In the AppBundle, I can build the whole app within the controllers and symfony offer me the framework to do. It will have some editing routes, admin routes and much more.

But what if the any user call http://example.com/unkownCustomer/someSite

If a someSite route is defined it will cause a problem, just because there is no valid customer. Sure I can handle it, on each Action, but that isn't very smart. I was thinking about extending the Controller class from symfony, to add some base funktionality for example extended the render method to add some basic stuff like customer settings for example the customer name to add it automaticaly in the parameters array for twig, that I don't have to do it explicit in every controller. I think some security features also have to be implemented more generally, that one authenticated user that have a role don't have this role on other customer sites or is not authenticated.

But how I can inject some code before I run the action functionality targeting the route? And the big question - what should be the right way to do? Do have to change my mind doing this thing in symfony?

PS: Sorry for my poor english - hope you will understand my problem.

ich
  • 1
  • 1
  • You can accomplish a task in many ways using a framework like Symfony and each developer could have a different approach (often based on own opinions). Symfony is a modular framework formed by many decoupled components and to know how to use it (and to understand how Symfony works) you need for first to study deeper the relative documentation that explain how to use every single feature of each component. Then you will be able to decide which components use to cover any needs of your app (and to resolve problem like this by yourself in the better way). – gp_sflover May 01 '16 at 21:03
  • Hi gp_sflover, thanks for your reply... I thought it's enough to read the basic in the book. Do you have a suggestion? I read something about events that might be useful for my problem. – ich May 02 '16 at 14:37

1 Answers1

0

I learned a lot in the last 2 days - and that video completly answer my question in a very good way doing it in a it think right way!

https://knpuniversity.com/screencast/question-answer-day/symfony2-dynamic-subdomains

ich
  • 1
  • 1