How to use Puli in your application? 22 // puli.json { "resources": { "/app": "app/Resources", "/custom-library": "vendor/..." } } Simplify access to resources
How to use Puli in your application? 23 require ‘vendor/autoload.php’; $puliClass = PULI_FACTORY_CLASS; $puli = new $puliClass(); $repo = $puli->createRepository(); Simplify access to resources
How to use Puli in your application? 24 echo $repo->get('/app/views/index.html.twig') ->getBody(); echo $repo->get('/app/views/index.html.twig') ->getFilesystemPath(); echo $repo->get('/custom-library'. .'/views/index.html.twig') ->getFilesystemPath(); Simplify access to resources
How to use Puli in your application? 28 // /vendor/acme/custom-library/puli.json { "resources": { "/views": "views", ... } } Simplify access to resources
How to use Puli in your application? 29 $ composer require acme/custom-library Updating dependencies (including require-dev) - Installing acme/custom-library (1.0.0) Downloading: 100% Synchronizing Puli with Composer Installing acme/custom-library Deleting the ".puli" directory Running "puli build" Simplify access to resources
How to use Puli in your application? 30 echo $repo->get('/acme/custom-library'. .'/views/index.html.twig') ->getFilesystemPath(); Simplify access to resources
How to use Puli in your application? 32 // your app puli.json { "resources": { "/app": "app", "/res": "app/Resources" }, "provide": { "/app/config/services.yml": "symfony/services", "/res/translations/*.yml": "symfony/translations" } } Autoload specialized files Defined by Symfony to load your files using Puli $discovery->findBindings('...')
How to use Puli in your application? 33 // /vendor/acme/custom-library/puli.json { "resources": { "/config": "res/config", "/translations": "res/translations" }, "provide": { "/config/symfony-services.yml": "symfony/services", "/config/pimple-services.yml": "pimple/services", "/config/php-di-services.yml": "php-di/services", "/translations/*.xlst": "php-fig/xlst-translations" } } Autoload specialized files Usable by libraries! Binding are not necessarily used by the “consumer”
How to use Puli in your application? 34 $ composer require acme/custom-library => Services available in your container => Translations available in your translator => Doctrine entities, Twig extensions, ... Autoload specialized files Plug’n’Play (even more than bundles!)
How to use Puli in your application? 37 // gulpfile.babel.js gulp.task('babel', () => gulp.src(puli.paths('/app/**/*.jsx') .pipe(babel()) .pipe(ulgify()) .pipe(header('(c) SensioLabs')) .pipe(gulp.dest('web/built/min.js')) ); Publish assets