• This repository has been archived on 03/Dec/2023
  • Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 7 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Speed up your package DI containers integration and console apps to Symfony and Nette

Package Builder

Downloads total

This tools helps you with Collectors in DependecyInjection, Console shortcuts, ParameterProvider as service and many more.

Install

composer require symplify/package-builder

Use

Get All Parameters via Service

  1. Register ParameterProvider service in your config:
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\PackageBuilder\Parameter\ParameterProvider;
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;

return static function (ContainerConfigurator $containerConfigurator): void {
    $services = $containerConfigurator->services();

    $services->defaults()
        ->autowire()
        ->autoconfigure();

    $services->set(ParameterProvider::class)
        ->args([service('service_container')]);

    $parameter = $containerConfigurator->parameters();
    // will be used later
    $parameter->set('source', 'src');
};
  1. Require ParameterProvider in __construct() where needed:
namespace App\Configuration;

use Symplify\PackageBuilder\Parameter\ParameterProvider;

final class ProjectConfiguration
{
    /**
     * @var ParameterProvider
     */
    private $parameterProvider;

    public function __construct(ParameterProvider $parameterProvider)
    {
        $this->parameterProvider = $parameterProvider;
    }

    public function getSource(): string
    {
        // returns "src"
        return $this->parameterProvider->provideParameter('source');

        // use specific typed method to avoid `mixed`
        return $this->parameterProvider->provideStringParameter('source');
    }
}

Get Vendor Directory from Anywhere

use Symplify\PackageBuilder\Composer\VendorDirProvider;

$vendorDirProvider = new VendorDirProvider();
// returns path to vendor directory
$vendorDirProvider->provide();

Smart Compiler Passes for Lazy Programmers ↓

How to add compiler pass?


Always Autowire this Type

Do you want to allow users to register services without worrying about autowiring? After all, they might forget it and that would break their code. Set types to always autowire:

namespace App;

use PhpCsFixer\Fixer\FixerInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symplify\PackageBuilder\DependencyInjection\CompilerPass\AutowireInterfacesCompilerPass;

final class AppKernel extends Kernel
{
    protected function build(ContainerBuilder $containerBuilder): void
    {
        $containerBuilder->addCompilerPass(new AutowireInterfacesCompilerPass([FixerInterface::class]));
    }
}

This will make sure, that PhpCsFixer\Fixer\FixerInterface instances are always autowired.


That's all :)

Show Diff in Console Colors

use Symplify\PackageBuilder\Console\Output\ConsoleDiffer;

final class SomeCommand
{
    public function __construct(
        private ConsoleDiffer $consoleDiffer
    ) {
    }

    public function run(): void
    {
        // prints colored diff to the console output
        $this->consoleDiffer->diff('oldContent', 'newContent');
    }
}

Report Issues

In case you are experiencing a bug or want to request a new feature head over to the Symplify monorepo issue tracker

Contribute

The sources of this package are contained in the Symplify monorepo. We welcome contributions for this package on symplify/symplify.

More Repositories

1

symplify

[DISCONTINUED] Check split packages in their own repositories :)
PHP
622
star
2

statie

[DEPRECATED] [READ-ONLY] Use Symfony plugin instead →
PHP
92
star
3

changelog-linker

[READ-ONLY] Make CHANGELOG.md Useful with Links
PHP
79
star
4

smart-file-system

[READ-ONLY] Use SmartFileInfo with useful methods that you need everyday
PHP
79
star
5

autowire-array-parameter

Autowire Array Parameters for Symfony applications
PHP
61
star
6

symfony-static-dumper

[DEPRECATED] Use standardized static site generators like Vercel, Statamatic etc.
PHP
51
star
7

set-config-resolver

[READ-ONLY] Loads configs to you with CLI --config, -c, --set, -s or sets parameter
PHP
50
star
8

symplify-kernel

Internal Kernel for Symplify packages
PHP
47
star
9

BetterPhpDocParser

[DEPRECATED] Moved to
PHP
43
star
10

easy-testing

[READ-ONLY] Testing made easy
PHP
42
star
11

symfony-route-usage

[READ-ONLY] Detect used and unused Symfony routes
PHP
41
star
12

console-color-diff

[DEPRECATED] Use PackageBuilder instead
PHP
40
star
13

git-wrapper

[READ-ONLY] PHP wrapper around the Git command line
PHP
38
star
14

ThemeBootstrap

[DEPRECATED] Merged to ApiGen main repository
HTML
37
star
15

composer-json-manipulator

[READ-ONLY] Manipulate composer.json with Beautiful Object API
PHP
36
star
16

rector-prefixed

[READ-ONLY] Prefixed version of Rector
PHP
34
star
17

TokenRunner

[Deprecated] Use directly →
PHP
32
star
18

pehapkari.cz-old

Website of Czech and Slovak PHP Community
PHP
31
star
19

easy-hydrator

[READ-ONLY] Hydrate arrays to objects with PHP 7.4 and constructor injection
PHP
30
star
20

auto-bind-parameter

[DEPRECATED] [READ-ONLY] Auto bind parameters in for your Symfony applications
PHP
28
star
21

console-package-builder

[READ-ONLY] Package to speed up building command line applications
PHP
27
star
22

astral

[READ-ONLY] Toolking for smart daily work with AST
PHP
25
star
23

migrify

Futuristic Grinder for Legacy Code with Effortles Confidence
PHP
25
star
24

ControllerAutowire

[DEPRECATED] Use Controller autowiring by default since Symfony 3.3
PHP
24
star
25

simple-php-doc-parser

[DEPRECATED] Use Astral instead
PHP
23
star
26

DoctrineMigrations

[DEPRECATED] Use Phinx instead
PHP
22
star
27

rector-cakephp

[DEPRECATED] Use following package instead
PHP
20
star
28

easy-ci

Swiss knife in pocket of every upgrade architect
PHP
19
star
29

markdown-diff

[READ-ONLY] Package to print diffs for Markdown
PHP
19
star
30

skipper

[READ-ONLY] Skip file by rule, path, regex or fnmatch
PHP
17
star
31

symfony-php-config

[DEPRECATED] Inlined in Rector/ECS directly as just 1 class
PHP
17
star
32

SymfonyModularRouting

[DEPRECATED] Decouple your Symfony routing to independent, standalone services.
PHP
17
star
33

phpstan-twig-rules

PHP
15
star
34

amnesia

[DEPRECATED] Use https://symfony.com/blog/new-in-symfony-5-3-config-builder-classes instead
PHP
15
star
35

DoctrineMethodsHydrator

[DEPRECATED] use arachne/entity-loader instead
PHP
14
star
36

NetteAdapterForSymfonyBundles

[DEPRECATED due to only 20 downloads per 2 years] Read an article about this idea
PHP
14
star
37

migrify-kernel

[READ-ONLY] [INTERNAL] Kernel for small CLI applications
PHP
13
star
38

gophp71.org

Website to promote and inform about PHP 7.1 as minimal requirement in PHP packages
HTML
12
star
39

rector-ci

PHP
12
star
40

CodingStandard

[DEPRECATED] Use EasyCodingStandard instead
PHP
12
star
41

DoctrineBehaviors

[DEPRECATED]
PHP
11
star
42

autodiscovery

[READ-ONLY] Forget manual registration of Doctrine entities, Twig templates and routes. Let autodiscovery handle that for you
PHP
11
star
43

rector-generator

[DEPRECATED] Save your typing the repeated Rector rule code and focus on writing refactor() method only
PHP
10
star
44

parameter-name-guard

[DEPRECATED] Use PHP configs with constants autocomplete instead
PHP
10
star
45

gomonorepo.org

All You Always Wanted to Know About Monorepo But Were Afraid to Ask
HTML
9
star
46

DoctrineFixtures

[READ-ONLY] Nelmio\Alice integration to Nette
PHP
9
star
47

reveal-src

Static analysis for your templates is here!
PHP
9
star
48

rector-nette-to-symfony

Rector rules for Nette to Symfony migration
PHP
8
star
49

twig-phpstan-compiler

PHP
8
star
50

rector-training

PHP
8
star
51

ActionAutowire

[DEPRECATED, READ-ONLY] Use:
PHP
8
star
52

Security

[DEPRECATED, MOVED to @Symplify] Integration of Firewall and Votres tfrom Symfony\Security to Nette DI
PHP
8
star
53

finalize

Safe way to finalize PHP - find classes with children, entities first to create guard map, finalize rest then with Rector
PHP
8
star
54

Monorepo

[READ-ONLY] Build and maintain monorepo (monolithic repository) like a boss
PHP
7
star
55

DefaultAutowire

[DEPRECATED] Use Symfony 3.3 instead, see →
PHP
6
star
56

flex-loader

[READ-ONLY] Load Entities, Twig paths, Routes and Services in Few Lines
PHP
6
star
57

latte-to-twig-converter

[READ-ONLY] [MOVED here →]
PHP
5
star
58

static-detector

[READ-ONLY] Detect static calls in your project
PHP
5
star
59

lavarle

Sexy utils for Laravel projects
PHP
5
star
60

ci-to-github-actions

[READ-ONLY] Converts Travis CI, Gitlab CI... to Github Actions
PHP
5
star
61

open-training

[READ-ONLY] Free platform for organizing lectures, from creating, over registration, to payments and lector provisions
PHP
5
star
62

barista

The Barista explores every Latte (file) for strict quality, helps with Latte 2 to 3 upgrade
PHP
5
star
63

presenter-route

[DEPRECATED] Routes for Nette single action presenters with HTTP methods support.
PHP
4
star
64

sniffer-fixer-to-ecs-converter

[READ-ONLY] Switch PHP_CodeSniffer or PHP-CS-Fixer to ECS with Single Command
PHP
4
star
65

easy-coding-standard-prefixed

[READ-ONLY] Prefixed version of ECS to prevent install conflicts on older version
PHP
4
star
66

reveal

Release repository
PHP
4
star
67

PHP7_CodeSniffer

[DEPRECATED] Use:
PHP
4
star
68

ModularLatteFilters

[READ-ONLY] Nette extension for modular Latte filters
PHP
4
star
69

migration-artefacts

PHP
3
star
70

reveal-twig

PHP
3
star
71

template-phpstan-compiler

PHP
3
star
72

ThemeDefault

[DEPRECATED] Integrated to ApiGen\ApiGen
HTML
3
star
73

Bootstrap

[DEPRECATED]
PHP
3
star
74

TitleComponent

[DEPRECATED] Title component for Nette
PHP
3
star
75

symfony-phpstan-rules

PHP
3
star
76

FlashMessageComponent

[DEPRECATED] Flash message component for Nette Framework
PHP
3
star
77

easy-coding-standard-tester

[READ-ONLY] The Best Way to Test Sniffs and Fixers
PHP
3
star
78

demo

How Rector works in Examples
PHP
3
star
79

latte-to-twig-converter-next

[READ-ONLY] Do you want to turn your Latte templates to Twig?
PHP
3
star
80

phpunit-upgrader

[READ-ONLY] Upgrade PHPUnit tests with smart helping hand
PHP
3
star
81

phpfwtrends.org

Site with statistics of PHP framework downloads - raw Packagist data over guessing and emotions
PHP
3
star
82

reveal-latte

PHP
2
star
83

ArachneEventDispatcher

[DEPRECATED] use contributte/event-dispatcher
PHP
2
star
84

class-presence

[READ-ONLY] Check NEON/YAML/TWIG/LATTE files for existing classes and class constants
PHP
2
star
85

NetteDatabaseFilters

[DEPRECATED]
PHP
2
star
86

psr4-switcher

[READ-ONLY] Switch classmap to PSR-4
PHP
2
star
87

template-checker

[READ-ONLY] Check your TWIG and Latte templates
PHP
2
star
88

neon-to-yaml-converter

[READ-ONLY] Do you want to turn your NEON files to YAML?
PHP
2
star
89

ServiceDefinitionDecorator

[DEPREACATED] Use _instanceof since Symfony 3.3
PHP
2
star
90

EventDispatcher

[DEPRECATED] use contributte/event-dispatcher
PHP
2
star
91

BetterReflectionDocBlock

[DEPRECATED] [READ-ONLY] Use → instead
PHP
2
star
92

ElementReflection

[DEPRECTAED] Element Reflection component for ApiGen
PHP
2
star
93

phpstan-php-config

[READ-ONLY] Use PHP config syntax to configure PHPStan in phpstan.php
PHP
2
star
94

form-validation-panel

[DISCONTINUED] Nette DebugBar tab that allows you to disable and enable Nette JS validation.
PHP
2
star
95

pehapkari

Pehapkari ecosystem tools
PHP
1
star
96

statie-tweet-publisher

[DEPREATED] Intergated directly in Statie 5.3+
PHP
1
star
97

react-datagrid

[DEPRECATED] 🌈 Simple datagrid in react
JavaScript
1
star
98

vendor-patch-files

Specific patch files for Symplify packages
1
star
99

Community

[DEPRECATED] Issue tracker for organizers
PostScript
1
star
100

rector-php71

[READ-ONLY] Split repository for PHP 7.1 version
PHP
1
star