{"id":15226371,"url":"https://github.com/leanphp/common-dev","last_synced_at":"2025-04-09T20:30:23.227Z","repository":{"id":62516661,"uuid":"79289593","full_name":"leanphp/common-dev","owner":"leanphp","description":"Common PHP Development Tools meta-package","archived":false,"fork":false,"pushed_at":"2018-04-14T00:06:52.000Z","size":744,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T22:24:15.075Z","etag":null,"topics":["apigen","behat","composer-package","developer-tools","development-tools","mockery","modern-php","php","php-codesniffer","php-composer","php-development","php-fig","php7","phploc","phpmd","phpspec","phpstan","phpunit","prophecy","vfsstream"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/leanphp/common-dev","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leanphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-18T01:12:09.000Z","updated_at":"2022-02-12T07:20:54.000Z","dependencies_parsed_at":"2022-11-02T15:01:14.805Z","dependency_job_id":null,"html_url":"https://github.com/leanphp/common-dev","commit_stats":null,"previous_names":[],"tags_count":49,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanphp%2Fcommon-dev","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanphp%2Fcommon-dev/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanphp%2Fcommon-dev/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leanphp%2Fcommon-dev/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leanphp","download_url":"https://codeload.github.com/leanphp/common-dev/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248107039,"owners_count":21048844,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apigen","behat","composer-package","developer-tools","development-tools","mockery","modern-php","php","php-codesniffer","php-composer","php-development","php-fig","php7","phploc","phpmd","phpspec","phpstan","phpunit","prophecy","vfsstream"],"created_at":"2024-09-28T20:04:51.276Z","updated_at":"2025-04-09T20:30:23.196Z","avatar_url":"https://github.com/leanphp.png","language":"PHP","readme":"common-dev\n==========\n[![License](https://img.shields.io/packagist/l/leanphp/common-dev.svg?style=flat-square)](#License)\n[![Latest Stable Version](https://img.shields.io/packagist/v/leanphp/common-dev.svg?style=flat-square)](https://packagist.org/packages/leanphp/common-dev)\n[![Total Downloads](https://img.shields.io/packagist/dt/leanphp/common-dev.svg?style=flat-square)](https://packagist.org/packages/leanphp/common-dev)\n[![Travis](https://img.shields.io/travis/leanphp/common-dev.svg?style=flat-square)](https://travis-ci.org/leanphp/common-dev)\n[![Pre Release](https://img.shields.io/packagist/vpre/leanphp/common-dev.svg?style=flat-square)](https://packagist.org/packages/leanphp/common-dev)\n\n[leanphp/common-dev][0] is a set of modern **PHP 7+** development tools and\nlibraries, which help you write PHP packages and libraries that comply with\n[PHP-FIG][1] standards and adhere to best PHP practices defined in [PHP - The\nRight Way][2] guidelines.\n\n**Note!** These tools help you write **well-tested** functional \u0026 **OOP** code\n([TDD][3], [BDD][4], [SOLID][5]). This meta-package should serve more as an\nexample set of development tools that one can use. This package helps when you\nwant to hack something quick, however for serious projects you are advised to\ncompile a custom list of development dependencies in `composer.json` of your\nproject, instead of depending on this package directly.\n\nSee [Packages](#Packages) for a list of packages that this meta-package\nprovides. [Usage](#Usage) section covers information regarding various tools\nand libraries. Additionally, we provide [example configuration\nfiles](#Configuration) for various tools that this package provides (`config/`\ndirectory).\n\n## Install\n\nInstall this package as a development requirement in your project:\n\n    $ composer require --dev leanphp/common-dev\n\n## Packages\n\nThis package will trigger installation of various PHP [Libraries](#Libraries)\nand [Development Tools](#Development Tools).\n\n### Libraries\n\nThis is a list of PHP Libraries that this package installs:\n\n- [symfony/var-dumper](#var-dumper) **v3** - Advanced Variable Dumper by\n  Symfony project (`dump()` instead of `var_dump()`).\n- [Mockery](#Mockery) **v1.0** - a simple yet flexible PHP mock object framework for\n  use in unit testing.\n- [Prophecy](#Prophecy) - highly opinionated mocking framework for PHP.\n- [Alice](#Alice) - Expressive Fixtures generator based on [Faker](#Faker).\n- [Faker](#Faker) - PHP Library to generate fake data for you.\n- [vfsStream](#vfsStream) - Virtual file system to mock the real file system in unit\n  tests.\n- [PHPUnit](#PHPUnit) **v6** - The PHP Unit Testing framework.\n- [PHPSpec](#PHPSpec) **v4** - SpecBDD / BDD Testing framework for PHP with extensions:\n    - [phpspec-code-coverage][805] - Code Coverage for [PHPSpec][800].\n    - [phpspec-typehintedmethods][810] - Generate Typehinted methods\n- [behat](#Behat) **v3** - ScenarioBDD / BDD Testing framework for PHP, with\n  extensions:\n    - [behat/mink-extension][950] - [Mink][400] extension for [behat][900].\n    - [behat/mink-goutte-driver][960] - [Goutte][450] driver for [Mink][400].\n    - [behat/mink-browserkit-driver][970] - Symfony BrowserKit driver for\n      [Mink][400].\n- [Mink](#Mink) - Browser Emulator / Abstraction framework for PHP.\n\n### Development Tools\n\nThis is a list of PHP Development Tools that this package installs:\n\n- [Sami](#Sami) - An API Documentation generator.\n- [PHPStan](#PHPStan) - PHP Static Analysis tool.\n- [PHPMD](#PHPMD) **v2** - PHP Mess Detector. Optimize your code, reduce\n  complexity, cleanup unused parameters, methods, variables \u0026 more.\n- [PHP_CodeSniffer](#PHP CodeSniffer) **v3** - PHP Code Sniffer ensures that\n  your code remains clean and consistent. It is a set of scripts to detect and\n  automatically correct violations of a defined coding standard.\n- [phpcs-symfony2-standard][140] - Symfony2 Coding Standard configuration for\n  [PHP_CodeSniffer][130].\n- [phpcpd](#phpcpd) - Copy/Paste Detector (CPD) for PHP code.\n- [phploc](#phploc) - a tool that quickly measures the size of your PHP project.\n- [composer][7] binary is also included in this package (`bin/composer`).\n\n## Usage\n\n**Note!** When executing command we will use `bin/command` as an example. This\nrequires `bin-dir` parameter set in `composer.json` of your project:\n\n```js\n    \"config\": {\n        \"bin-dir\": \"bin\"\n    },\n```\n\nIf `bin-dir` is not set, use `./vendor/bin` prefix when running command line tools.\n\n### Libraries\n\n#### var-dumper\n\n[symfony/var-dumper][110] is an Advanced Variable Dumper by  Symfony project.\nIt provides developer with `dump()` function which is a better alternative to\n`var_dump()` or `print_r()`. It provides well formatted output, which adapt\ndepending on context (console, browser) and packs nice additional features.\n\nThis package add **global function** `dump()`, which can be called from\nanywhere in your code:\n\n```php\n    \u003c?php\n    require 'vendor/autoload.php';\n\n    $date = new \\DateTime()\n    dump($date)\n```\n\n**Note!** Try executing the example snippet above in the console AND then\nbrowser to see the differences.\n\n#### Mockery\n\n[Mockery][210] is a simple yet flexible PHP mock object framework for use in\nunit testing with [PHPSpec](#PHPSpec) or [PHPUnit](#PHPUnit). It allows you to\nmock objects in tests, so the tests run faster and do not have to initialize\nthe dependencies directly. For an alternative approach, make sure to check\n[Prophecy](#Prophecy).\n\nMockery is integrated with [PHPUnit](#PHPUnit), but can be used with any\ntesting framework.\n\nFor more information check [Mockery Documentation page][211].\n\n#### Prophecy\n\n[Prophecy][220] is a highly opinionated mocking framework for PHP. It was\ninitially created for [PHPSpec](#PHPSpec) needs but it is flexible to be used\nin any testing framework ([PHPUnit](#PHPUnit), [Behat](#Behat)). It approaches\ntesting from a different angle than [Mockery](#Mockery) because it concentrates\non describing the future behaviour of objects, instead of mocking them.\n\nFor more information check [Prophecy Repository on Github][220].\n\n#### Alice\n\n[Alice][240] is an Expressive Fixtures generator based on [Faker](#Faker). It\nallows you to quickly create fixtures (fake data) while developing or testing\nyour PHP code. Alice is very useful while working with projects, based on\nSymfony, Doctrine, Zend or any other framework. For testing your packages, you\ncan just use [Faker](#Faker) directly.\n\nFor more information check [Alice repository on GitHub][240].\n\n#### Faker\n\n[Faker][250] is PHP Library to generate fake data for you. Whether you need to\nbootstrap your database, create good-looking XML documents or just need any\nfake data, Faker is for you. If you need a solution that integrated well with\nSymfony, Doctrine, Zend or any other frameworks, check [Alice](#Alice) (based\non Faker).\n\nBasic fake usage:\n\n```php\n\u003c?php\n\nrequire 'vendor/autoload.php';\n// use the factory to create a Faker\\Generator instance\n$faker = Faker\\Factory::create();\n\n// generate data by accessing properties\necho $faker-\u003ename;\n// 'Lucy Cechtelar';\necho $faker-\u003eaddress;\n// \"426 Jordy Lodge\n// Cartwrightshire, SC 88120-6700\"\necho $faker-\u003etext;\n// Dolores sit sint laboriosam dolorem culpa et autem. Beatae nam sunt fugit\n// et sit et mollitia sed.\n```\n\nFor more information check [Faker repository on GitHub][250].\n\n#### vfsStream\n\n[vfsStream][300] is Virtual file system to mock the real file system in unit\ntests. It comes in handy when you need to perform file operations in your code\nand want them to be thoroughly tested. It's best to abstract such tests by\nusing a virtual file system and vfsStream allows you to do that.\n\nFor more information check [vfsStream Wiki on GitHub][301].\n\n#### PHPUnit\n\n[PHPUnit][200] is The PHP Unit Testing framework. It's an industry proven and\nstandard unit testing framework for PHP. If you prefer to do simple TDD instead\nof BDD - [behat][900] (StoryBDD) or [PHPSpec][800] (SpecBDD), then this is your\ntest tool of choice.\n\nIn order to setup PHPUnit for your project, you can use example\n[phpunit.xml](config/phpunit.xml) configuration file.\n\nCopy it to the root of your project:\n\n    $ cp vendor/leanphp/common-dev/config/phpunit.xml phpunit.xml\n\nIf your tests are NOT stored in `tests/` directory, adjust the `\u003ctestsuites\u003e`\ntag in `phpunit.xml`. The file provides additional comments and settings that\ncan be useful when setting up PHPUnit for your project PHP package.\n\nRun PHPUnit tests:\n\n    $ bin/phpunit\n\nPHPUnit will generate various reports (defaults to `build/` directory), which\ncan be used by various tools when analyzing your code and tests (i.e. test code\ncoverage generation).\n\nFor more information check [PHPUnit Documentation][201].\n\n#### PHPSpec\n\n[PHPSpec][800] is a SpecBDD ([BDD][4]) Testing framework for PHP. It is\nspecification oriented testing framework. It allows you to define your tests,\nwhich then are used to generate PHP Classes, based on the defined\nspecification. PHPSpec is also great for unit testing.\n\nIn order to setup PHPSpec for your project, you can use example\n[phpspec.yml](config/phpspec.yml) configuration file.\n\nCopy it to the root of your project:\n\n    $ cp vendor/leanphp/common-dev/config/phpspec.yml phpspec.yml\n\nThe configuration file will enable all the PHPSpec extensions that come\ninstalled with this package.\n\n**Note!** Due to PSR-4 you have to set the default PSR-4 namespace in\n`phpspec.yml` which is set to `LeanPHP\\Common` in the example `phpspec.yml`.\n**Make sure to change it to your package's namespace!**.\n\nWrite your first spec file `spec/ClassSpec.php`:\n\n```php\n\u003c?php\n\nnamespace spec\\LeanPHP\\Common;\n\nuse PhpSpec\\ObjectBehavior;\n\nclass ClassSpec extends ObjectBehavior\n{\n    function it_can_say_hello()\n    {\n        $this-\u003esay('hello')-\u003eshouldReturn('hello');\n    }\n}\n```\n\nRun PHPSpec to generate the class, based on the defined specification:\n\n    $ bin/phpspec run\n\nPHPSpec will fail the test, but will ask you to generate the classes for you.\n\nFor more information check [PHPSpec Documentation page][801].\n\n#### Behat\n\n[behat][900] is a ScenarioBDD / BDD Testing framework for PHP. It allows you to\ndefine your tests in human readable scenario format, based on gherkin language.\nIt offers a very basic, yet effective test scenario structure. It has became\na standard ScenarioBDD/BDD tool for PHP. It integrated well with\n[PHPSpec](#PHPSpec) and [Mink](#Mink). The latter makes it perfect for\n**functional testing**.\n\nIn order to setup Behat for your project, you can use example\n[behat.yml](config/behat.yml) configuration file.\n\nCopy it to the root of your project:\n\n    $ cp vendor/leanphp/common-dev/config/behat.yml behat.yml\n\nInitialize the project:\n\n    $ bin/behat --init\n\nThe configuration file will enable all the Behat extensions that come\ninstalled with this package and will also integrate it with\n[PHPSpec](#PHPSpec).\n\n**Note!** The default configuration uses [mink-goutte-driver][960] extension by\ndefault. If you want integration with Symfony based project, switch to\n[mink-browserkit-driver][870].\n\nFor more information check [Behat Quick Start][902] and consult [Behat\nDocumentation page][901].\n\n#### Mink\n\n[Mink][400] is a Browser Emulator / Abstraction framework for PHP. It allows\nyou to simulate a browser in your tests. It's functionality is based on\ndifferent drivers that it supports. It is able to integrate with\n[Selenium][460], [Goutte][450] and other browsers to run your tests with. While\nit can be used as a standalone tool, it is a core part of [Behat](#Behat) and\nit does not require any special configuration, besides what is covered in\n[Behat](#Behat) section.\n\nFor more information check [Mink Homepage][400].\n\n### Development Tools\n\n#### Sami\n\n[Sami][100] is an API documentation generator. It generates API documentation\nfor your PHP source code (classes, interfaces, traits, methods etc.). Have\na look at [Symfony API](http://api.symfony.com/) to see a working example of\nwhat Sami does.\n\nYou can start with example [sami.php](config/sami.php) configuration file.\n\nCopy it to the root of your project:\n\n    $ cp vendor/leanphp/common-dev/config/sami.php .sami.php\n\nPlease check comments in `.sami.php` and customize it according to your needs.\n\nGenerate the API:\n\n    $ bin/sami update .sami.php\n\nThe API Documentation will be generated in `build/docs/\u003cversion\u003e` directory,\nwhich is configured in `.sami.php`.\n\n#### PHPStan\n\n**Note!** PHPSten is temporarily not provided by the package as it conflicts\nwith ApiGen. Additionally we believe we need to review the usability of some of\nthe other tools if we also bring PHPStan.\n\n[PHPStan][115] is a PHP Static Analysis Tool. It focuses on finding errors in\nyour code without actually running it. It catches whole classes of bugs even\nbefore you write tests for the code.\n\n`PHPStan` is run via console:\n\n    $ bin/phpstan analyse src tests\n\n#### PHPMD\n\n[PHPMD][120] (PHP Mess Detector) is a code optimizer, which scans your code for\ncomplexity, unused parameters, methods. It helps developers optimize their PHP\ncode. It can also point out more problematic areas of your code, that need\nrefactoring or are too complex. It's a great tool in any PHP developers\ntoolbox.\n\nPHP Mess Detector is highly configurable and you can define different [rulese][121].\nIt is best to use example [phpmd.xml](config/phpmd.xml) configuration file,\nwhich has all of them enabled and customize from there.\n\nCopy it to the root of your project:\n\n    $ cp vendor/leanphp/common-dev/config/phpmd.xml phpmd.xml\n\nPHPMD is run via console:\n\n    $ bin/phpmd \u003cSOURCE_DIR\u003e \u003cFORMAT\u003e \u003cRULESET_FILENAME\u003e\n\nYou can generate a text formatted report for your source code in `src/`\ndirectory, but using `phpmd.xml` ruleset:\n\n    $ bin/phpmd src/ text phpmd.xml\n\n**Note!** Consult [PHPMD Documentation on Rules][121] when customizing\n`phpmd.xml` for your project!\n\n#### PHP CodeSniffer\n\n[PHP_CodeSniffer][130](#PHP CodeSniffer) ensures that your code remains clean\nand consistent. It is a set of scripts to detect and automatically correct\nviolations of a defined coding standard. It is extremely useful to keep the\ncode consistent, especially when there are multiple developers working on one\nproject. It is also helpful when working alone as it will make you write more\nconsistent code.\n\nIt is best to use example [phpcs.xml](config/phpcs.xml) configuration file as it has a Symfony based coding standard defined, which will give you a good start.\n\nCopy the example config to the root of your project:\n\n    $ cp vendor/leanphp/common-dev/config/phpcs.xml phpcs.xml\n\nIf your source code is NOT stored in `src/` directory, adjust the `\u003cfile\u003e` tag\nin `phpcs.xml`. Additionally, make sure that any test or build directories are\nexcluded (via `\u003cexclude-pattern\u003e` tag).\n\nTo get a list of coding standard violations, Run PHP CodeSniffer tool:\n\n    $ bin/phpcs\n\nPHP CodeSniffer also includes a tool which allows you to fix many of these\nviolations automatically:\n\n    $ bin/phpcbf\n\n#### phpcpd\n\n[phpcpd][150] is a Copy/Paste Detector (CPD) for PHP code. It allows you to\nscan your PHP files and detect duplicate code (likely a Copy/Paste). This is\na code that likely needs refactoring. It's a great tool to improve the quality\nof your code.\n\nTo scan `src/` directory and detect problematic areas in your code:\n\n    $ bin/phpcpd src/\n\n#### phploc\n\n[phploc][160] is a tool that quickly measures the size of your PHP project. It\nscans the structure of your PHP Source Code and returns various statistics\nabout it (such as number of Classes, Methods, Variables etc.).\n\nIn order to scan source code directory `src/`:\n\n    $ bin/phploc src/\n\n## Configuration\n\nYou can find example configuration files for the tools and libraries in\n`config/` directory. Included example config files:\n\n- [apigen.yaml](config/apigen.yaml) - [ApiGen](#ApiGen) example config.\n- [phpcs.xml](config/phpcs.xml) - [PHP_CodeSniffer](#PHP CodeSniffer) Coding\n  Standard config.\n- [phpmd.xml](config/phpmd.xml) - [PHPMD](#PHPMD) example config.\n- [phpunit.xml](config/phpunit.xml) - [PHPUnit][200] example config.\n- [phpspec.yml](config/phpspec.yml) - [phpspec][800] example config.\n- [behat.yml](config/behat.yml) - [behat][900] example config.\n\nThese configuration files must either be placed in the root of your repository\nor you have to point configuration file manually when using a specific tool.\nMost of the time making a copy of the file in the project's root and\ncustomizing it should be sufficient.\n\n## Change Log\n\nPlease see [CHANGELOG.md](CHANGELOG.md) for information of what was changed.\n\n## Author\n\nCopyright (c) 2012-2017 ek9 \u003cdev@ek9.co\u003e (https://ek9.co)\n\n## License\n\nLicensed under [MIT License](LICENSE).\n\n[0]: https://packagist.org/packages/leanphp/common-dev\n[1]: http://www.php-fig.org\n[2]: http://www.phptherightway.com\n[3]: https://en.wikipedia.org/wiki/Test-driven_development\n[4]: https://en.wikipedia.org/wiki/Behavior-driven_development\n[5]: https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)\n[6]: https://packagist.org\n[7]: https://getcomposer.org\n\n[100]: https://github.com/FriendsOfPHP/Sami\n[110]: https://github.com/symfony/var-dumper\n[115]: https://github.com/phpstan/phpstan\n[120]: https://phpmd.org\n[121]: https://phpmd.org/rules/index.html\n[130]: https://pear.php.net/package/PHP_CodeSniffer\n[140]: https://github.com/leaphub/phpcs-symfony2-standard\n[150]: https://github.com/sebastianbergmann/phpcpd\n[160]: https://github.com/sebastianbergmann/phploc\n[200]: https://phpunit.de\n[201]: https://phpunit.de/documentation.html\n[210]: https://github.com/padraic/mockery\n[211]: http://docs.mockery.io/en/latest/index.html\n[220]: https://github.com/phpspec/prophecy\n[240]: https://github.com/nelmio/alice\n[250]: https://github.com/fzaninotto/Faker\n[300]: https://github.com/mikey179/vfsStream\n[301]: https://github.com/mikey179/vfsStream/wiki\n[400]: http://mink.behat.org\n[450]: https://github.com/FriendsOfPHP/Goutte\n[460]: http://docs.seleniumhq.org\n[800]: http://www.phpspec.net\n[801]: http://www.phpspec.net/en/stable/manual/introduction.html\n[805]: https://github.com/leanphp/phpspec-code-coverage\n[810]: http://github.com/ciaranmcnulty/phpspec-typehintedmethods\n[900]: http://behat.org\n[901]: http://behat.org/en/latest/guides.html\n[902]: http://behat.org/en/latest/quick_start.html\n[950]: http://extensions.behat.org/mink\n[960]: https://github.com/minkphp/MinkGoutteDriver\n[970]: https://github.com/minkphp/MinkBrowserKitDriver\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanphp%2Fcommon-dev","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleanphp%2Fcommon-dev","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleanphp%2Fcommon-dev/lists"}