Milan Felix Šulc
📦 Package maker • 👷 Architect ModernTV • 🐘 PHP enthusiast • 💿 Multimedia engineer • 👨👩👧👦 Father • ☕️ Coffee-based
composer create-project nette/web-project$config = new Configuration();
//..
$connectionParams = array(
    'dbname' => 'mydb',
    'user' => 'user',
    'password' => 'secret',
    'host' => 'localhost',
    'driver' => 'pdo_mysql',
);
$conn = DriverManager::getConnection(
    $connectionParams, 
    $config
);composer require nettrine/dbalCompilerExtension
Tracy
Classes
extensions:
    dbal: Nettrine\DBAL\DI\DbalExtension
dbal:
    debug: %debugMode%
    connection:
        host: localhost
        driver: mysqli
        dbname: nettrine
        user: root
        password: rootdbal:
    debug: %debugMode%
    connection:
        host: localhost
        driver: mysqli
        dbname: nettrine
        user: root
        password: root
    foo: 1dbal:
    debug: %debugMode%
    connection:
        host: localhost
        driver: mysqli
        dbname: nettrine
        user: root
        password: root
    foo: 1Expect::structure([
    'debug' => Expect::bool(false),
    'configuration' => Expect::structure([
        'sqlLogger' => Expect::string()->nullable(),
        'resultCacheImpl' => Expect::string()->nullable(),
        'autoCommit' => Expect::bool(true),
    ]),
    'connection' => Expect::array()->default([
        'driver' => 'pdo_sqlite',
        'types' => [],
        'typesMapping' => [],
    ]),
]);extensions:
    dbal: Nettrine\DBAL\DI\DbalExtension
dbal:
    debug: true/false
    connection:
        host: localhost
        driver: mysqli
        dbname: nettrine
        user: root
        password: rootextensions:
    dbal: Nettrine\DBAL\DI\DbalExtension
dbal:
    debug: %debugMode%
    connection:
        host: localhost
        driver: mysqli
        dbname: nettrine
        user: root
        password: root/**
 * @ORM\Entity(repositoryClass="App\UserRepository")
 * @ORM\Table(name="`user`")
 * @ORM\HasLifecycleCallbacks
 */
class User
{
	/**
	 * @ORM\Column(
            type="string", 
            length=255, 
            nullable=FALSE, 
            unique=TRUE
           )
	 */
	private $email;
}composer require nettrine/ormcomposer require nettrine/ormcomposer require contributte/console➕
❤️
composer require symfony/consolecomposer require nettrine/cacheextensions:
    orm: Nettrine\ORM\DI\OrmExtension
    orm.cache: Nettrine\ORM\DI\OrmCacheExtensionextensions:
    orm: Nettrine\ORM\DI\OrmExtension
    orm.cache: Nettrine\ORM\DI\OrmCacheExtension
orm.cache
    defaultDriver: apcu$user = new User(
    'Felix',
    'Felicis',
    'milan@sulc.dev'
);
$em->persist($user);
$em->flush();
$faker = Faker\Factory::create();
$user = new User(
    $faker->firstName,
    $faker->lastName,
    $faker->email
);
$em->persist($user);
$em->flush();
User::class => [
    'user{0..100}' => [
        '__construct' => [
            '<firstName()>',
            '<lastName()>',
            '2 (unique)' => '<email()>',
        ],
    ],
],User::class => [
    'user{0..100}' => [
        '__construct' => [
            '<firstName()>',
            '<lastName()>',
            '2 (unique)' => '<email()>',
            '@address_<current>'
        ],
    ],
],
Address::class => [
    'address_{0..100}' => [
        '__construct' => [
            '<street()>',
            '<city()>',
        ],
    ],
],composer require nettrine/dbal
composer require nettrine/orm
composer require nettrine/fixtures
composer require contributte/console
composer require nelmio/aliceextensions:
    # Doctrine DBAL
    dbal: Nettrine\DBAL\DI\DbalExtension
    dbal_console: Nettrine\DBAL\DI\DbalConsoleExtension
    # Doctrine ORM
    orm: Nettrine\ORM\DI\OrmExtension
    orm_cache: Nettrine\ORM\DI\OrmCacheExtension
    orm_console: Nettrine\ORM\DI\OrmConsoleExtension
    orm_annotations: Nettrine\ORM\DI\OrmAnnotationsExtension
    # Data Fixtures
    fixtures: Nettrine\Fixtures\DI\FixturesExtension
fixtures:
    paths:
        - %appDir%/db/Fixtures
class UserFixture extends AbstractFixture
{
    public function load(ObjectManager $manager): void
    {
        $loader = new NativeLoader();
        $users = $loader->loadData([
            User::class => [
                'user{0..100}' => [
                    '__construct' => [
                        '<firstName()>',
                        '<lastName()>',
                        '2 (unique)' => '<email()>',
                    ],
                ],
            ],
        ]);
        foreach($users as $user) {
            $manager->persist($user);
        }
        $manager->flush();
    }
}
composer require nettrine/migrationsextensions:
	migrations: Nettrine\Migrations\DI\MigrationsExtension
migrations:
	table: doctrine_migrations
	column: version
	directory: %appDir%/db/Migrations
	namespace: Database\Migrations
	versionsOrganization: nullbin/console migrations:migratecomposer require nettrine/annotations/**
 * @Component\Component(name="user_list")
 * @Component\Security(role="admin")
 * @Component\Cache(expire="+20 minutes")
 */💰
💰
💰
💰
use Doctrine\Common\Annotations\Annotation\Target;
/**
 * @Annotation
 * @Target("CLASS")
 */
final class Component
{
    /** @var string */
    public $name;
}/**
 * @Component\Component(name="user_list")
 * @Component\Security(role="admin")
 */
final class UserListFactory implements IControlFactory
{
	public function create(?array $args = null)
	{
		return new UserList(...);
	}
}public function loadConfiguration(): void
{
    $builder = $this->getContainerBuilder();
    $builder->addDefinition($this->prefix('creator'))
        ->setFactory(ComponentCreator::class);
}public function beforeCompile(): void
{
    $builder = $this->getContainerBuilder();
    $components = $builder->findByType(IControlFactory::class);
    foreach ($components as $service => $def) {
        $this->parseAnnotations($def->getType());
    }
}services:
  - App\Components\UserListFactoryprotected function parseAnnotations(string $class)
{   
    $reader = new AnnotationReader();
    $rc = new ReflectionClass($class);
    $annotations = $reader->getClassAnnotations($rc);
    foreach ($annotations as $annotation) {
        // Parse @Component
        if (get_class($annotation) === Component::class) {
            $metadata['name'] = $annotation->name;
            continue;
        }
        // Other annotations..
    }
}public function beforeCompile(): void
{
    // ...
    $creator = $builder->getDefinition($this->prefix('creator'));
    foreach ($metadata as $item) {
        $creator->addSetup('register', [
            $item['name'], 
            $item['def']
        ]);
    }
}class BasePresenter
{
    /** @var IModalsControlFactory @inject */
    public $modalsControlFactory;
    public function createComponentModals(): ModalsControl
    {
        return $this->modalsControlFactory->create();
    }
}class ModalsControl
{
    protected function createComponent($name): BaseModal
    {
       return $this->creator->create($name, $args);
    }
}
{control modals-user_list}
NEON (factories)
CompilerExtension
Component Creator
Latte
{control xyz}
Annotation Reader
Nette 3.0! 👍
shut
UP
and
take
my
moniez
💰💵
💰
💰
💰
?
What? Why? How? No? Oh.
Keep Contributting!
@xf3l1x
f3l1x.io
By Milan Felix Šulc
📦 Package maker • 👷 Architect ModernTV • 🐘 PHP enthusiast • 💿 Multimedia engineer • 👨👩👧👦 Father • ☕️ Coffee-based