Created
August 11, 2017 20:06
-
-
Save rogersguedes/4e0df177fd8261e2a8f76dd065972d92 to your computer and use it in GitHub Desktop.
Codeigniter Method for Doctrine console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
| use Symfony\Component\Console\Input; | |
| class app_console extends CI_Controller{ | |
| public function __construct(){ | |
| parent::__construct(); | |
| } | |
| public function doctrine() { | |
| $this->load->database(); | |
| $conn = array( | |
| "driver" => "pdo_mysql", | |
| "user" => $this->db->username, | |
| "password" => $this->db->password, | |
| "host" => $this->db->hostname, | |
| "port" => $this->db->port, | |
| "dbname" => $this->db->database, | |
| "charset" => $this->db->char_set | |
| ); | |
| $this->load->library("Doctrine", $conn); | |
| $helperSet = \Doctrine\ORM\Tools\Console\ConsoleRunner::createHelperSet($this->doctrine->em); | |
| $cli = new Symfony\Component\Console\Application('Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION); | |
| $cli->setCatchExceptions(true); | |
| $cli->setHelperSet($helperSet); | |
| \Doctrine\ORM\Tools\Console\ConsoleRunner::addCommands($cli); | |
| $tash = array('trash'); | |
| $params = func_get_args(); | |
| $params = array_merge($tash, $params); | |
| $args2 = new \Symfony\Component\Console\Input\ArgvInput($params); | |
| $cli->run($args2); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment