Skip to content

Instantly share code, notes, and snippets.

View wouterj's full-sized avatar

Wouter de Jong wouterj

View GitHub Profile
<?php
// ...
class MyUnit
{
private $authChecker;
public function __construct(AuthorizationCheckerInterface $authChecker)
{
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
pattern: ^/
provider: db_provider
anonymous: ~
<?php
class PostController extends Controller
{
public function showAction($slug, $_template)
{
$post = $this->someBackend->findBySlug($slug);
return $this->render($_template, ['post' => $post]);
}

Every request, get the current logged in user (on the PC, no idea how they plan to implement this) and authenticate this user in the app (creating a new user if it doesn't exists yet).

<?php
// ...
class MailLogger implements LoggerInterface
{
private $mailer;
public function __construct(MailerInterface $mailer)
{
$this->mailer = $mailer;
$ composer require --no-update symfony/framework-bundle "~2.3.3|~2.6.6"
$ composer require --no-update symfony/symfony "*"
$ composer update -q
$ composer show -i
...
symfony/framework-bundle v2.6.12
symfony/symfony          v2.8.1
[PDOException]
SQLSTATE[HY000]: General error: 1 no such table: phpcr_workspaces
Exception trace:
() at C:\sf-world\cmf\standard-edition\vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php:691
PDO->prepare() at C:\sf-world\cmf\standard-edition\vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php:691
Doctrine\DBAL\Connection->executeQuery() at C:\sf-world\cmf\standard-edition\vendor\doctrine\dbal\lib\Doctrine\DBAL\Connection.php:419
Doctrine\DBAL\Connection->fetchColumn() at C:\sf-world\cmf\standard-edition\vendor\jackalope\jackalope-doctrine-dbal\src\Jackalope\Transport\DoctrineDBAL\Client.php:409

How to Prepare Your Bundle for Symfony 3

Symfony 3 is a major version update of Symfony. This means that code working on Symfony 2 applications might not work on Symfony 3. In order to update your bundles for Symfony 3, you need to make sure that your bundle doesn't use any of the removed features without also using the replacement. This guide will teach you how to add Symfony 3 support to your bundle and it'll also give you some practical tips to support both Symfony 2 and 3.

<?php
namespace App;
require __DIR__.'/vendor/autoload.php';
use Symfony\Component\Console\Application;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleCommandEvent;
use Symfony\Component\Console\Input\InputArgument;