PHPackages                             mtarld/symbok-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. [Database &amp; ORM](/categories/database)
4. /
5. mtarld/symbok-bundle

AbandonedArchivedSymfony-bundle[Database &amp; ORM](/categories/database)

mtarld/symbok-bundle
====================

Symbok Annotation Bundle

2.2.1(5y ago)491.5k1MITPHPPHP ~7.2.5|^7.3|^7.4

Since Mar 24Pushed 3y ago2 watchersCompare

[ Source](https://github.com/mtarld/symbok-bundle)[ Packagist](https://packagist.org/packages/mtarld/symbok-bundle)[ RSS](/packages/mtarld-symbok-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (20)Versions (13)Used By (0)

⚠️ Status: Archived
===================

[](#warning-status-archived)

With PHP 8.1 and the emergence of public readonly properties, this bundle repository has been archived and is no longer maintained.

If you really need to generate getters and setters generation, you can have a look at [lombok-php](https://github.com/MarcinOrlowski/lombok-php).

Symbok Annotation Bundle
========================

[](#symbok-annotation-bundle)

[![Packagist](https://camo.githubusercontent.com/12b75949189b6951b4fe2965c6c0f43068b8f48e53443f7bf1b0160fc177cacb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7461726c642f73796d626f6b2d62756e646c652e737667)](https://camo.githubusercontent.com/12b75949189b6951b4fe2965c6c0f43068b8f48e53443f7bf1b0160fc177cacb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d7461726c642f73796d626f6b2d62756e646c652e737667)[![GitHub](https://camo.githubusercontent.com/a7af9b98a061b3ea6f775f28e8670a9af168102f16afcce5f792e3b8c2065e23/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7461726c642f73796d626f6b2d62756e646c652e737667)](https://camo.githubusercontent.com/a7af9b98a061b3ea6f775f28e8670a9af168102f16afcce5f792e3b8c2065e23/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6d7461726c642f73796d626f6b2d62756e646c652e737667)[![Actions Status](https://github.com/mtarld/symbok-bundle/workflows/CI/badge.svg)](https://github.com/mtarld/symbok-bundle/actions)

Runtime code generator bundle for Symfony.

- Detects classes that are using Symbok annotations, generates related methods and loads generated class instead of the original one.
- Stores generated classes in Symfony cache so that Symbok compiles them just once.
- Reads basic Doctrine annotations to handle property's type, nullable status and entity relation.

Initially inspired by [Plumbok](https://github.com/plumbok/plumbok).

Compatible with Symfony 4 and 5

Symbok ?
--------

[](#symbok-)

> 👋 Bye bye endless PHP classes !

Symbok provides annotations in order to generate on the fly predictable and repetitive methods.

Available annotations are:

- AllArgsConstructor
- Data
- ToString
- Getter
- Setter
- Nullable

Symbok also parses doctrine properties annotations such as `Column`, `JoinColumn`, `OneToOne`, `OneToMany`, `ManyToOne`, `ManyToMany` in order to automatically discover property type, nullable status and adapt generated methods.

You'll be able to find more precise information on Symbok Bundle in the [documentation](src/Resources/doc/index.md)

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

You can easily install Symbok by composer

```
$ composer require mtarld/symbok-bundle

```

Then, bundle should be registered. Just verify that `config\bundles.php` is containing :

```
Mtarld\SymbokBundle\SymbokBundle::class => ['all' => true]
```

### Configuration

[](#configuration)

Once Symbok is installed, you should configure it to fit your needs.

To do so, edit `config/packages/symbok.yaml`

```
# config/packages/symbok.yaml

symbok:
    # Namespaces that you wanna be processed
    namespaces:
        - 'App\Entity'
        - 'App\Model'

    defaults:
        getter: ~
            # If getters are nullable by default (default true)
            nullable: ~

        setter: ~
            # If setters are fluent by default (default true)
            fluent: ~

            # If setters are nullable by default (default true)
            nullable: ~

            # If setters should update other side when relation is detected (default true)
            updateOtherSide: ~

        constructor:
            # If constructor uses nullable parameters (default true)
            nullable: ~
```

And you're ready to go ! 🚀

Basic example
-------------

[](#basic-example)

Register your namespace in config file

```
# config/packages/symbok.yaml

symbok:
    namespaces:
      - 'App\Entity'
```

Then edit your class by adding annotations

```
