PHPackages                             kjonski/how-to-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kjonski/how-to-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

kjonski/how-to-bundle
=====================

Step-by-step Symfony bundle tutorial

1122PHP

Since Mar 22Pushed 8y ago1 watchersCompare

[ Source](https://github.com/kjonski/how-to-bundle)[ Packagist](https://packagist.org/packages/kjonski/how-to-bundle)[ RSS](/packages/kjonski-how-to-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

[![Build Status](https://camo.githubusercontent.com/1c135b201d775f59f6be6767ca8103babe75401af342413244b6fc818b8d8f3b/68747470733a2f2f7472617669732d63692e6f72672f6b6a6f6e736b692f686f772d746f2d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kjonski/how-to-bundle)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/4a3c547bb7163913bd4f073650ef1d6037745f703c824de3a6f037109a22cd32/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6a6f6e736b692f686f772d746f2d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kjonski/how-to-bundle/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/c45f30f32ae058272f7e3d1300d61a8b4cdfd156a9ed6534868dc0401fe7357e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6a6f6e736b692f686f772d746f2d62756e646c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kjonski/how-to-bundle/?branch=master)

how-to-bundle
=============

[](#how-to-bundle)

Step-by-step tutorial how to prepare Symfony bundle

Prepare repository
------------------

[](#prepare-repository)

Prepare bundle repository in the way you like. You can use Github or local repository. Be advised that repository need to be accessible by your future project.
With Github wizard you can add README.md and LICENSE
[![Github repository wizard](../master/src/Resources/images/github_repository_wizard.png "Github repository wizard")](../master/src/Resources/images/github_repository_wizard.png)

Clone repository
----------------

[](#clone-repository)

```
git clone https://github.com/kjonski/how-to-bundle.git
```

and open with editor.

Add `composer.json` file
------------------------

[](#add-composerjson-file)

```
{
    "name": "kjonski/how-to-bundle",
    "type": "symfony-bundle",
    "description": "Step-by-step Symfony bundle tutorial",
    "keywords": ["php", "symfony", "reusable bundle", "tutorial"],
    "license": "MIT",
    "authors": [
        {
            "name": "Karol Jonski",
            "email": "kjonski@pgs-soft.com"
        }
    ]
}
```

commit and push changes.

Configure project's repository
------------------------------

[](#configure-projects-repository)

If you want develop bundle inside existing project and unless bundle isn't in [packagist.org](https://packagist.org/) please configure main project's `composer.json`. Add/modify `repositories` section:

```
"repositories": [
    {
        "type": "git",
        "url": "https://github.com/kjonski/how-to-bundle.git"
    }
],
```

when using Github repository, or:

```
"repositories": [
    {
        "type": "git",
        "url": "/path/to/how-to-bundle.git"
    }
],
```

when using local repository. For more details @see [Composer documentation](https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository).

Install you bundle with composer
--------------------------------

[](#install-you-bundle-with-composer)

```
$ composer require kjonski/how-to-bundle
```

Prepare structure
-----------------

[](#prepare-structure)

`b$` means vendor/yourVendorName/yourBundle (`vendor/kjonski/how-to-bundle`) directory.

```
b$ mkdir src
b$ mkdir tests
```

Configure autoloading in your `composer.json`
---------------------------------------------

[](#configure-autoloading-in-your-composerjson)

```
"autoload": {
    "psr-4": { "Kjonski\\HowToBundle\\": "src/" }
},
"autoload-dev": {
    "psr-4": {
        "Kjonski\\HowToBundle\\Tests\\": "tests/"
    }
}
```

Install dependencies
--------------------

[](#install-dependencies)

```
b$ composer require symfony/dependency-injection
b$ composer require --dev symfony/http-kernel
b$ composer require --dev phpunit/phpunit
```

Add bundle class
----------------

[](#add-bundle-class)

```

            .

            ../src

                ../vendor

```

- You can see KERNEL\_CLASS configured because for some cases you will need own [kernel](../master/tests/App/AppKernel.php) for phpunit.
- Please add `tests/coverage.xml` to ignored files.

Now you are ready to run your test suite:

```
b$ vendor/bin/phpunit -c tests/phpunit.xml
```

Time for code quality tools
---------------------------

[](#time-for-code-quality-tools)

Install:

```
b$ composer require --dev phpstan/phpstan
b$ composer require --dev sebastian/phpcpd
b$ composer require --dev squizlabs/php_codesniffer
b$ composer require --dev friendsofphp/php-cs-fixer
```

add [php-cs-fixer.config.php](../master/tests/php-cs-fixer.config.php), [phpstan.neon](../master/tests/phpstan.neon) (optional) and run:

```
b$ vendor/bin/php-cs-fixer fix --config=tests/php-cs-fixer.config.php --dry-run --diff src tests
b$ vendor/bin/phpcs --report-full --standard=PSR2 src tests
b$ vendor/bin/phpstan analyse --level=4 src -c tests/phpstan.neon
b$ phpdbg -qrr vendor/bin/phpunit -c tests/phpunit.xml
```

Build? Oh, yes!
---------------

[](#build-oh-yes)

- Go to  and follow instruction to enable Travis builds for your (Github) repository.
- Add simple [.travis.yml](../master/.travis.yml) or follow [Symfony Continuous Integration](http://symfony.com/doc/current/bundles/best_practices.html#continuous-integration).
    From now build will be run on every push to your repository.
- Now you can go to your Travis profile -&gt; your repository, grab your build badge and add to `README.md`
    [![Build badge](../master/src/Resources/images/travis_ci_build_badge.png "Travis build bagde")](../master/src/Resources/images/travis_ci_build_badge.png)

More badges?
------------

[](#more-badges)

- Go to  and Sign Up with Github
- Add repository
- Update configuration

```
build:
  nodes:
      analysis:
          ...
          tests:
              override:
                  ...
                  -
                      command: vendor/bin/phpunit -c tests/phpunit.xml
                      coverage:
                          file: 'tests/coverage.xml'
                          format: 'clover'
...
```

to enable code coverage.

- Run inspection
- Get badges from summary screen
    [![Build badge](../master/src/Resources/images/scrutinizer_summary.png "Scrutinizer bagdes")](../master/src/Resources/images/scrutinizer_summary.png)

Go live with packagist
----------------------

[](#go-live-with-packagist)

- Go to  and submit your bundle
- Configure [GitHub Service Hook](https://packagist.org/about#how-to-update-packages) to keep your package up to date
- Remember to remove your local/Github repository from project's `composer.json` repositories section

Sources
-------

[](#sources)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6838531?v=4)[Karol Joński](/maintainers/kjonski)[@kjonski](https://github.com/kjonski)

---

Top Contributors

[![kjonski](https://avatars.githubusercontent.com/u/6838531?v=4)](https://github.com/kjonski "kjonski (17 commits)")

### Embed Badge

![Health badge](/badges/kjonski-how-to-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kjonski-how-to-bundle/health.svg)](https://phpackages.com/packages/kjonski-how-to-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
