PHPackages                             litvinenko/app - 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. litvinenko/app

ActiveLibrary

litvinenko/app
==============

General-purpose Litvinenko\\Common\\App class that can dispatch events in Magento style and create singletones in Magento style

v0.0.4(10y ago)0481PHPPHP &gt;=5.4.0

Since Jan 7Pushed 10y ago1 watchersCompare

[ Source](https://github.com/absent1706/common_php_app)[ Packagist](https://packagist.org/packages/litvinenko/app)[ RSS](/packages/litvinenko-app/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (5)Used By (1)

\#General-purpose App class

It can:

- dispatch events in Magento style (see  or )
- create singletones in Magento style (see )

This class uses Magento-like XML config files (see ).

\##Installation Just install it throw composer. Create composer.json file in your app directory, fill it with

```
{
    "require":
    {
        "litvinenko/app": "*"
    }
}
```

and run

```
composer install

```

\##To init App Just run \\Litvinenko\\Common\\App::init() method and pass to it path to your config file (default path is 'config.xml'). This will register all events and observers.

XML config file for this app is very similar to Magento XML config files (see ).

It should look like:

```

                    MyClass
                    myMethod

                    MyOtherClass
                    myOtherMethod
                    1

    0

```

\##To dispatch events using App: firstly, init app:

```
\Litvinenko\Common\App::init()
```

then, in any place you need paste:

```
App::dispatchEvent('event_name', array('param1' => $value1, 'param2' => $value2, ...));
```

For example,

```
App::dispatchEvent('language_learned', array('language' => $language, 'learner' => $this));
```

\##Working example:

XML file ('example\_config.xml')

```

                    Logger
                    logLearnedLanguage

                    Learner
                    printLearnedLanguages
                    1

    0

```

PHP file

```
