PHP code example of metglobal / composer-service-handler

1. Go to this page and download the library: Download metglobal/composer-service-handler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

metglobal / composer-service-handler example snippets


namespace App\Repository;

use Metglobal\ServiceHandler\Annotation\Service;

/**
 * @Service(
 *     id="app.repository.my_repository",
 *     factory= {"@doctrine.orm.default_entity_manager", "getRepository"},
 *     arguments={"App:MyEntity"},
 *     calls={
 *          {"setSender", {"@App\Mailer\Sender"}}
 *     }
 *    )
 */
class MyRepository {

}

namespace App\EventListener;

use Metglobal\ServiceHandler\Annotation\Service;
use Metglobal\ServiceHandler\Annotation\Tag;

/**
 * @Service(
 *     id="app.event_listener.my_listener",
 *     arguments={
 *          "@App\Repository\MyRepository",
 *          "@App\Mailer\Sender"     
 *     },
 *     tags={
 *          @Tag(name="kernel.event_listener", event="success", method="onSuccess"),
 *          @Tag(name="kernel.event_listener", event="fail", method="onFail")
 *     }
 *    )
 */
class MyListener {

}