PHP code example of foreverglory / doctrine-manager

1. Go to this page and download the library: Download foreverglory/doctrine-manager 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/ */

    

foreverglory / doctrine-manager example snippets


//src:DependencyInjection/AppExtension.php
namespace AppBundle\DependencyInjection;

class AppExtension extends Extension
{

    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);

        //通过配置参数,设置manager的class
        $container->getDefinition('doctrine.manager.example')
                ->addMethodCall('setClass', [$config['app_class']]);

    }
}

$this->get('doctrine.manager.example')->find($id);
$this->get('doctrine.manager.example')->findAll();
$this->get('doctrine.manager.example')->findOneBy($criteria);
$this->get('doctrine.manager.example')->findBy($criteria);
$this->get('doctrine.manager.example')->create($properties);
$this->get('doctrine.manager.example')->update($properties);
$this->get('doctrine.manager.example')->delete($properties);
$this->get('doctrine.manager.example')->getManager();
$this->get('doctrine.manager.example')->getRepository();