Beispiel #1
0
<?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();
Beispiel #2
0
<?php

if (file_exists(__DIR__ . '/../../autoload.php')) {
    require __DIR__ . '/../../autoload.php';
} else {
    require __DIR__ . '/vendor/autoload.php';
}
use Yuloh\Ketch\Commands;
$app = new Silly\Application('Ketch', '0.1.0');
$app->command('create name [template]', new Commands\Create())->defaults(['template' => 'yuloh/ketch'])->descriptions('Create a new project', ['name' => 'The project name, i.e. "my-project"', 'template' => 'The Template\'s Github repository, i.e. "yuloh/ketch"']);
$app->run();
<?php

require_once __DIR__ . '/../bootstrap.php';
$commandGateway = $app->commandGateway();
$silly = new Silly\Application();
$helpers = $silly->getHelperSet();
$questionHelper = $helpers->get('question');
require_once 'app-install-command.php';
require_once 'register-user-command.php';
require_once 'change-username-command.php';
require_once 'change-user-password-command.php';
require_once 'list-users-command.php';
$silly->run();
Beispiel #4
0
<?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()));
Beispiel #5
0
use PhpParser\NodeTraverser;
use PhpParser\ParserFactory;
use PhpParser\NodeVisitor\NameResolver;
use GuzzleHttp\Client as Http;
use GuzzleHttp\ClientInterface as IHttp;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use League\Flysystem\AdapterInterface as IFileAdapter;
use League\Flysystem\FilesystemInterface as IFilesystem;
use Stash\Pool as Cache;
use Stash\Driver\Ephemeral as CacheDriver;
use Stash\Interfaces\PoolInterface as ICache;
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