PHPackages                             forci/static-data-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. forci/static-data-bundle

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

forci/static-data-bundle
========================

Static Data Import for applications that need pre-defined entities with IDs

v1.0.0(2mo ago)010.4k↓33.3%MITPHPPHP &gt;=8.5

Since Jan 20Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/forci/static-data-bundle)[ Packagist](https://packagist.org/packages/forci/static-data-bundle)[ RSS](/packages/forci-static-data-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (15)Used By (0)

Installation
============

[](#installation)

`composer require forci/static-data-bundle`

Add the bundle to your bundles array

```
new \Forci\Bundle\StaticData\ForciStaticDataBundle(),
```

Configure your bundles. These are the bundles that have StaticData that needs to be imported

```
forci_static_data:
    bundles:
        - App
        # Note: Your bundle can be configured as a string or full-blown config.
        # You can also specify your entity manager if not "default" or if you have many
        # For advanced usage, please refer to the Configuration file of this bundle.
        - Api
        -
           bundle: Frontend
           # Note: When looking up classes, this bundle converts slashes to namespace separators
           directory: Some/Directory
           em: some_other_em
        - Admin
```

The Static Data bundle will look into each `bundle`'s configured `directory` (`StaticData` by default) and pick all `*Data.php` files. Then, if there is a service with an ID equal to the FQCN, or if the class is a subclass of `Forci\Bundle\StaticData\StaticData\StaticData`, it will be constructed and added to a ``Forci\\Bundle\\StaticData\\StaticData\\DataCollection`. Note, that this only happens on-demand and will *NOT* slow down your application's performance besides having to load another bundle and process its configs.

Usage
=====

[](#usage)

By default, you need to place your StaticData files in `BundleRootDir/StaticData`. Take a look at the below example for a bundle named `App` (Please notice the missing Bundle suffix! if you're using it, you need to specify the full bundle name in your config, eg AppBundle)

```
