Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Удачи и приятного рефакторинга!
use Symfony\Component\DependencyInjection\ContainerBuilder; $container = new ContainerBuilder(); $container->register('mailer', 'Mailer');
$ find . | grep -E 'php|phtml|inc$' | wc -l
8071
$ find . | grep -E 'php|phtml|inc$' | xargs cat | wc -l
1180995
$ echo phphphphxxxxx | grep -E 'php|phtml|inc$'
phphphphxxxxx
Вот у вас в строчке, которой вы меряетесь, ошибка:
Количество точно не значит качество.
Nginx + Varnish + Memcached
class Something
{
protected $Model;
function __construct($model_class = 'Model')
{
$this->Model = new $model_class(...);
}
function doSomething()
{
$this->Model->....;
}
}
<?php
use foo/bar;
use your/exception as exception;
use pdo, pdoexception;
require 'sinatra'
get '/' do
'Hello, Habr!'
end
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/', function () {
echo "Hello, Habr!";
});
$app->run();
$mailer = $this->container->get('mailer');
/** @var $mailer Mailer */
$mailer = $this->container->get('mailer');
// файл сервиса
class TestService
{
/**
* @var MailerInterface
*/
protected $mailer;
public function __construct(MailerInterface $mailer)
{
$this->mailer = $mailer;
}
}
services:
test_service:
class: \TestService
arguments: [@mailer]
Как реанимировать ваш PHP-проект с помощью Symfony2 компонентов