Kategorie: Symfony & PHP
Solution for "Undefined offset" at explode()
Use array_pad to populate the array: list($var1, $var2) = array_pad(explode(',', $queryString, 2), 2, null);
Add anchor to Knp Paginator sorting link
$paginator = $this->get('knp_paginator'); $pagination = $paginator->paginate( $query, $request->query->getInt('page', 1), 5 ); $pagination->setParam('_fragment', 'anchor');
Convert numeric utf8 to utf8
This converts \x47\x4c\x4fB\x41\x4c\x53 to GLOBALS foreach($letters as $letter) { $content = str_replace("\x".dechex(ord($letter)),$letter,$content); }
Get list of available time zone as array in PHP
\DateTimeZone::listIdentifiers(\DateTimeZone::ALL);
symfony 2: Asset directories default as symlinks
Add "symfony-assets-install": "symlink" to your composer.json file. Example: "extra": { "symfony-app-dir": "app", "symfony-web-dir": "web", "symfony-assets-install": "symlink" }
symfony2: Get base URL in twig
You can use the {{ app.request.getSchemeAndHttpHost() }} command to get the current host and scheme.
Symfony2: Fatal Error: Call to undefined method Symfony\Component\ClassLoader\DebugUniversalClassLoader::useIncludePath()
Die Fehlermeldung Call to undefined method Symfony\Component\ClassLoader\DebugUniversalClassLoader::useIncludePath() nach einem Update kann man folgendermaßen beheben. Führe folgenden Befehl auf der höchsten Ebene deines Projektes aus: php vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php
symfony2: Schnellreferenz
Create application out of hello dir: ./console init:application Foo ../foo/ ../web/ Create bundle: ./console init:bundle Application/FooBundle
symfony: Überschreiben eines Plugin schemas
Das folgende Beispiel demonstriert, wie man in symfony mit doctrine ORM die schema.yml eines Plugins überschreiben kann, um Modifikationen vor zu nehmen. schema.yml in sfDoctrineGuardPlugin: sfGuardUser: actAs: [Timestampable] columns: ... Eigene schema.yml: sfGuardUser: package: sfDoctrineGuardPlugin.lib.model.doctrine <Modifikationen>
symfony 1.3 1.4: Ausgabe beim project:deploy
Durch den -t Parameter wird die Ausgabe wie man es von früheren Version gewohnt ist erzeugt: ./symfony project:deploy -t production