<?php require_once 'vendor/autoload.php'; ini_set("log_errors", "on"); ini_set("error_log", "e:/temp/php_error.log"); $app = new Silly\Application(); $container = (require 'config/container.php'); $app->useContainer($container); $app->command("database [operation]", function ($operation) use($container) { /** @var \Doctrine\ORM\EntityManager $em */ $em = $container->get('EntityManager'); if ($operation == "create") { //Generate Database from map $classes = $em->getMetadataFactory()->getAllMetadata(); $schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em); //$schemaTool->updateSchema($classes); $schemaTool->createSchema($classes); } else { if ($operation == "entity") { //Generate Entities from map //$generator = new \Doctrine\ORM\Tools\EntityGenerator(); //$generator->generate($classes, 'E:\Ely\projects\sites\ddd\expressive\src\FNBr\Domain\Model\\');//OutputDir $metadata = getEntitiesMetaData($em); generateEntities('E:\\Ely\\projects\\sites\\ddd\\expressive\\src\\', $metadata); } else { if ($operation == "import") { //Generate Map from database $config = $container->get('config'); $classesToImport = $models = $config['models']; $namespace = $config['namespace'] . "\\Domain\\Model\\"; $em->getConfiguration()->setMetadataDriverImpl(new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($em->getConnection()->getSchemaManager()));
<?php use SuperBlog\Model\ArticleRepository; use Symfony\Component\Console\Output\OutputInterface; $container = (require __DIR__ . '/app/bootstrap.php'); $app = new Silly\Application(); // Silly will use PHP-DI for dependency injection based on type-hints $app->useContainer($container, $injectWithTypeHint = true); // Show the article list // This command is implemented using a closure. We can still benefit from dependency // injection in the parameters of the closure because Silly + PHP-DI is awesome. $app->command('articles', function (OutputInterface $output, ArticleRepository $repository) { $output->writeln('<comment>Here are the articles in the blog:</comment>'); $articles = $repository->getArticles(); foreach ($articles as $article) { $output->writeln(sprintf('Article #%d: <info>%s</info>', $article->getId(), $article->getTitle())); } }); // Show an article // For this command we provide an invokable class instead of a closure // That allows to use dependency injection in the constructor $app->command('article [id]', 'SuperBlog\\Command\\ArticleDetailCommand'); $app->run();
use Stash\Interfaces\DriverInterface as ICacheDriver; // Create a new silly cli app // see: http://mnapoli.fr/silly/ $app = new Silly\Application(); // We will use php-di as our IoC container // see: http://php-di.org/ $builder = new ContainerBuilder(); // We need to somehow do the caching at build time. // And then only read from the cache when we detect // that we are running inside a phar. //$builder->writeProxiesToFile(); //$builder->setDefinitionCache(); $builder->useAnnotations(true); $builder->addDefinitions(['vendor.dir' => 'ppm_packages', 'packagist.url' => 'https://packagist.org/packages/', 'semver.minimum-stability' => 'stable', IHttp::class => object(Http::class), IFilesystem::class => object(Filesystem::class), IFileAdapter::class => function () { return new Local(getcwd()); }, ICache::class => object(Cache::class), ICacheDriver::class => object(CacheDriver::class), Contracts\IConflictDiscoverer::class => object(Services\ConflictDiscoverer::class), Contracts\IPackageCleaner::class => object(Services\PackageCleaner::class), Contracts\IZipExtractor::class => object(Services\ZipExtractor::class), Contracts\IPackageReNamer::class => object(Services\PackageReNamer::class), Contracts\IComposerFileReader::class => object(Services\ComposerFileReader::class), Contracts\IPackageDownloader::class => object(Services\PackageDownloader::class), Contracts\ISemVerSolver::class => object(Services\SemVerSolver::class), Contracts\ITypeExtractor::class => object(Services\TypeExtractor::class), Contracts\IReNameVisitor::class => object(Services\ReNameVisitor::class), Contracts\IProxyGenerator::class => object(Services\ProxyGenerator::class), Contracts\IAutoLoaderGenerator::class => object(Services\AutoLoaderGenerator::class), IParser::class => function () { return (new ParserFactory())->create(ParserFactory::PREFER_PHP7); }, ITraverser::class => object(NodeTraverser::class)->method('addVisitor', get(NameResolver::class))]); // Make silly use php-di $app->useContainer($builder->build(), true, true); // Define our commands $app->command('init', 'Brads\\Ppm\\Commands\\Initalise'); $app->command('install', 'Brads\\Ppm\\Commands\\Install')->descriptions('Installs the project dependencies from the composer.lock ' . 'file if present, or falls back on the composer.json.'); $app->command('update', 'Brads\\Ppm\\Commands\\Update'); $app->command('remove', 'Brads\\Ppm\\Commands\\Remove'); $app->command('require', 'Brads\\Ppm\\Commands\\Require'); $app->command('global', 'Brads\\Ppm\\Commands\\Global'); $app->command('create-project', 'Brads\\Ppm\\Commands\\CreateProject'); $app->command('self-update', 'Brads\\Ppm\\Commands\\SelfUpdate'); // Run the cli application $app->run();