PHPackages                             net\_bazzline/php\_component\_locator\_generator - 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. net\_bazzline/php\_component\_locator\_generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

net\_bazzline/php\_component\_locator\_generator
================================================

Free as in freedom php component that generates configuration based hard coded locator

2.0.9(10y ago)2880[2 issues](https://github.com/bazzline/php_component_locator_generator/issues)5LGPL-3.0PHPPHP &gt;=5.3.3CI failing

Since Aug 31Pushed 4y ago4 watchersCompare

[ Source](https://github.com/bazzline/php_component_locator_generator)[ Packagist](https://packagist.org/packages/net_bazzline/php_component_locator_generator)[ RSS](/packages/net-bazzline-php-component-locator-generator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (7)Versions (24)Used By (5)

Locator Generator
=================

[](#locator-generator)

This free as in freedom component easy up locator generation based on configuration files. Out of the box, it creates locator from an array configuration file and from propel1 schema.xml files.

It is using the [php code generator component](https://github.com/bazzline/php_component_code_generator) as a robust base for code generation.

The build status of the current master branch is tracked by Travis CI: [![Build Status](https://camo.githubusercontent.com/d0af89255c7da4bd2e42dfa52d32353ef713414458acbd8726682b4ec2ee82f8/68747470733a2f2f7472617669732d63692e6f72672f62617a7a6c696e652f7068705f636f6d706f6e656e745f6c6f6361746f725f67656e657261746f722e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/bazzline/php_component_locator_generator)[![Latest stable](https://camo.githubusercontent.com/d663e0e1befb9cbbcba1b0ad43ae194ec4d1865d643456bac5cb7d1fea5019f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65745f62617a7a6c696e652f7068705f636f6d706f6e656e745f6c6f6361746f725f67656e657261746f722e737667)](https://packagist.org/packages/net_bazzline/php_component_locator_generator)

The scrutinizer status are: [![code quality](https://camo.githubusercontent.com/38919e98d562087ebda2e8915f7519b06e0fd1d601fa48d489bbe6ac23d9cd73/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617a7a6c696e652f7068705f636f6d706f6e656e745f6c6f6361746f725f67656e657261746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bazzline/php_component_locator_generator/) | [![build status](https://camo.githubusercontent.com/8bae907f0f05d410ab4be5cf6d1b8658ff33cd039c6ae0491f4008c3106a9770/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617a7a6c696e652f7068705f636f6d706f6e656e745f6c6f6361746f725f67656e657261746f722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bazzline/php_component_locator_generator/)

The versioneye status is: [![dependencies](https://camo.githubusercontent.com/1cb52f41addd3a511b8e90fb06e397f1dd1fba1be74dc8f57a5b523bf2f24e94/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3533653438633233653061323239313732663030303134362f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/53e48c23e0a229172f000146)

Downloads: [![Downloads this Month](https://camo.githubusercontent.com/e83e89478c808372e18a403952da7f134701b93c0a445b78bf89e5187bd1b91f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6e65745f62617a7a6c696e652f7068705f636f6d706f6e656e745f6c6f6361746f725f67656e657261746f722e737667)](https://packagist.org/packages/net_bazzline/php_component_locator_generator)

It is also available at [openhub.net](http://www.openhub.net/p/718779).

Why
===

[](#why)

- don't like "serviceLocator-&gt;get('foo')" (inexplicit API) calls
- like the configurable approach of some service locators out there
- inspired by a [php usergroup](http://artodeto.bazzline.net/archives/525-Social-Human-Architecture-for-Beginners-and-the-Flip-Side-of-Dependency-Injection-PHPUGHH.html) presentation called "[the flipside of dependency injection](http://thephp.cc/dates/2014/phpughh/the-flip-side-of-dependency-injection)" i'Ve seen "i'm not alone"
- generated code is easy debug- and understandable (no magic inside)

How
===

[](#how)

- a task specific configuration assembler creates a unified configuration object
- unified configuration object is injected into the locator generator
- the locator generator creates needed files
- a file exists strategy can take care how to deal with existing files

Install
=======

[](#install)

By Hand
-------

[](#by-hand)

```
mkdir -p vendor/net_bazzline/php_component_locator_generator
cd vendor/net_bazzline/php_component_locator_generator
git clone https://github.com/bazzline/php_component_locator_generator

```

With [Packagist](https://packagist.org/packages/net_bazzline/php_component_locator_generator)
---------------------------------------------------------------------------------------------

[](#with-packagist)

```
composer require net_bazzline/php_component_locator_generator:dev-master

```

Example
=======

[](#example)

Array Configuration File
------------------------

[](#array-configuration-file)

Take a Look to [configuration file](https://github.com/bazzline/php_component_locator_generator/blob/master/example/ArrayConfiguration/configuration.php).

### How To Create

[](#how-to-create)

```
cd
./execute_example ArrayConfiguration
ls data/
vim data/FromArrayConfigurationFileLocator.php
```

### Generated Code

[](#generated-code)

```
