update, install, create-project
create-project) → Applikationensymfony/standard-editionsymfony/framework-bundlecontao/standard-editioncontao/core-bundleapp.php...)
contao/contao
contao/core-bundle
contao/installation-bundleinstall.php!)contao/core-bundle, gilt als Erweiterungcontao/[...]-bundlecontao/core-bundle um zu funktionierenEin Bundle …
(Der Vollständigkeitshalber)
$> sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony
$> sudo chmod a+x /usr/local/bin/symfony
$> symfony new contao4-as-a-bundle 2.8
composer.json (1)contao/contao vs. contao/core-bundle
"require": {
"contao/contao": "~4.1"
},
composer.json (2)
"scripts": {
"post-install-cmd": [
"Contao\\CoreBundle\\Composer\\ScriptHandler::generateRandomSecret",
"Contao\\CoreBundle\\Composer\\ScriptHandler::addDirectories",
"Contao\\CoreBundle\\Composer\\ScriptHandler::generateSymlinks"
],
"post-update-cmd": [
"Contao\\CoreBundle\\Composer\\ScriptHandler::generateRandomSecret",
"Contao\\CoreBundle\\Composer\\ScriptHandler::addDirectories",
"Contao\\CoreBundle\\Composer\\ScriptHandler::generateSymlinks"
]
},
composer.json (3)
"config": {
"bin-dir": "bin",
"preferred-install": {
"contao/*": "source",
"contao-components/*": "source",
"*": "dist"
},
"component-dir": "assets"
},
composer.json (4)
"extra": {
"incenteev-parameters": {
"file": "app/config/parameters.yml",
"env-map": {
"secret": "CONTAO_RANDOM_SECRET"
}
}
}
// app/AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new ContaoCoreBundle(),
];
return $bundles;
}
}
app/config/contao.yml erstellen
# app/config/contao.yml
contao:
prepend_locale: "%prepend_locale%"
encryption_key: "%kernel.secret%"
prepend_locale muss im parameters.yml nachgetragen werden
contao.yml muss in der config.yml importiert werden
# app/config/config.yml
imports:
# Other imports
- { resource: contao.yml }
composer install wiederholencomposer run-script post-install-cmd
⇢ php app/console debug:router
-------------------------- -------- -------- ------ --------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ --------------
_wdt ANY ANY ANY /_wdt/{token}
[...]
homepage ANY ANY ANY /
-------------------------- -------- -------- ------ --------------
# app/config/routing.yml
ContaoCoreBundle:
resource: "@ContaoCoreBundle/Resources/config/routing.yml"
# app/config/routing_dev.yml
ContaoInstallationBundle:
resource: "@ContaoInstallationBundle/Resources/config/routing.yml"
⇢ php app/console debug:router
-------------------------- -------- -------- ------ -----------------
Name Method Scheme Host Path
-------------------------- -------- -------- ------ -----------------
[...]
homepage ANY ANY ANY /
contao_backend ANY ANY ANY /contao
[...]
contao_frontend ANY ANY ANY /{alias}.html
contao_index ANY ANY ANY /
contao_catch_all ANY ANY ANY /{_url_fragment}
Es kann nur einen security-Node geben, daher muss die security.yml von Hand zusammengeführt werden.
security:
providers:
[...] Your own providers
contao.security.user_provider:
id: contao.security.user_provider
security:
firewalls:
install: [...]
backend:
pattern: ^/contao
frontend:
pattern: ~
Keine Fehler? Dann sollte Contao erfolgreich installiert worden sein.
⇢ php app/console contao:version 4.1.3
install.php aus der Contao Standard Edition in deinen web/ Ordner kopieren.domain.tld/install.php aufrufen.
catch-all-Route zur VerfügungIn computer science, a function or expression is said to have a side effect if it modifies some state or has an observable interaction with calling functions or (sic!) the outside world. https://en.wikipedia.org/wiki/Side_effect_(computer_science)
Contao funktioniert als Bundle
handleRequestToken in ContaoFramework überschreiben.
// src/AppBundle/Contao/ContaoFramework.php
private function handleRequestToken()
{
return;
}
Ist bereits gefixt!
// src/AppBundle/EventListener/UserSessionListener.php
protected function hasUser()
{
$user = $this->tokenStorage->getToken();
return (
!$user instanceof AnonymousToken &&
!$user instanceof AppBundle\Entity\User
);
}
Controller::getFrontendModule($id)
class ContaoDataProviderExtension
{
public function renderFrontendModule($id)
{
$this->container->enterScope('frontend');
$this->framework->initialize();
$this->container->leaveScope('frontend');
return Controller::replaceInsertTags(Controller::getFrontendModule($id));
}
}
InlineFragmentRenderes und ControllerReferences.
class SimpleControllerReferenceModule extends Module
{
protected $strTemplate = 'mod_simple_controller_reference';
protected function compile()
{
$container = $this->getContainer();
$request = $container->get('request');
$response = $container->get('fragment.renderer.inline')->render(
new ControllerReference($this->controllerReference),
$request
);
$this->Template->content = $response->getContent();
}
}