Ver Mensaje Individual
  #4 (permalink)  
Antiguo 20/04/2012, 13:46
Avatar de Uncontroled_Duck
Uncontroled_Duck
Colaborador
 
Fecha de Ingreso: mayo-2011
Ubicación: Málaga [Spain]
Mensajes: 806
Antigüedad: 12 años, 11 meses
Puntos: 261
Respuesta: CronJob al estilo PHPUnit

Prácticamente es como tener el archivo index y un controller en el mismo archivo.

Al final me ha quedado así una prueba con doctrine:
Código PHP:
Ver original
  1. // Define path to application directory
  2. defined('APPLICATION_PATH')
  3.         || define('APPLICATION_PATH',
  4.         realpath(dirname(__FILE__) . '/../../../application'));
  5.  
  6. // Define application environment
  7. defined('APPLICATION_ENV')
  8.         || define('APPLICATION_ENV',
  9.         (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));
  10.  
  11. // Ensure library/ is on include_path
  12. set_include_path(implode(PATH_SEPARATOR, array(
  13.             realpath(APPLICATION_PATH . '/../library'),
  14.             get_include_path(),
  15.         )));
  16.  
  17. /** Zend_Application */
  18. require_once 'Zend/Application.php';
  19.  
  20. // Create application, bootstrap
  21. $application = new Zend_Application(
  22.                 APPLICATION_ENV,
  23.                 APPLICATION_PATH . '/configs/application.ini'
  24. );
  25. $application->bootstrap(); #Solo que no he aplicado el '->run()'
  26.  
  27. $doctrineContainer = Zend_Registry::get('doctrine');
  28.  
  29. $doctrine = Zend_Registry::get('doctrine');
  30. $entityManager = $doctrine->getEntityManager();
  31. $repository = $entityManager->getRepository('\Entities\Entity\Site');
  32.  
  33. $result = $repository->findAll();
  34. var_dump($result);
Aunque tengo que hacer más pruebas, por ahora anda con Doctrine que es lo que más me preocupaba.

Pero pregunto, al no añadir las líneas que indicas masterpuppet influye en algo?
Código PHP:
Ver original
  1. $service = $app->getBootstrap()->getContainer()->get('Application\Service\Products');
  2. $service->processBatch();
Al ponerlas me daba error, he buscado en la clase Bootstrap y en la doc de Zend y no he encontrado nada de que hace exactamente.

Aún así gracias por indicarme el camino, me ha sido de gran ayuda, como siempre

Un saludo,
__________________
Todos agradeceremos que pongas el código en su respectivo Highlight