dev-master
9999999-dev https://github.com/netgusto/Symfony-DynamicSubdomainBundleSymfony2 Dynamic subdomain handler Bundle
MIT
The Requires
- php >=5.3.3
by Net Gusto
symfony subdomain
Wallogit.com
2017 © Pedro Peláez
Symfony2 Dynamic subdomain handler Bundle
In composer.json:, (*1)
"require": {
"netgusto/dynamic-subdomain-bundle": "dev-master"
}
In app/AppKernel.php:, (*2)
$bundles = array(
# [...]
new Netgusto\DynamicSubdomainBundle\NetgustoDynamicSubdomainBundle(),
# [...]
);
In app/config.yaml, (*3)
netgusto_dynamic_subdomain:
base_host: netgusto.com
parameter_name: ~
entity: Acme\DemoBundle\Entity\MySite
property: ~
base_host:, (*4)
netgusto.com
parameter_name:, (*5)
Request
subdomain
entity:, (*6)
Acme\DemoBundle\Entity\MySite
property:, (*7)
subdomain
method:, (*8)
findOneBy
Request objectIn php, assuming that netgusto_dynamic_subdomain.property equals subdomain (the default value):, (*9)
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller {
public function indexAction(Request $request) {
$subdomainobject = $request->attributes->get('subdomain');
var_dump($subdomainobject);
}
In twig, assuming that netgusto_dynamic_subdomain.property equals subdomain (the default value), and that the entity mapped to subdomains has a title property:, (*10)
{{ app.request.attributes.get('subdomain').title }}
If the subdomain is not found in the database, an exception will be thrown by the Bundle (Symfony\Component\HttpKernel\Exception\NotFoundHttpException)., (*11)
Symfony2 Dynamic subdomain handler Bundle
MIT
symfony subdomain