[fw-general] Setup environment for cronjob

2009-05-23 Thread Саша Стаменковић
Hi to all.

I have Zend framework app created by Zend Tool, with default project
structure. I use models, and my library, everithing is set up, autoload.. My
bootstrap file:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initAutoload() {
return new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default_',
'basePath'  => dirname(__FILE__),
));
}
protected function _initDb() {
$db = $this->getPluginResource('db');

// Debug SQL
if ('testing' == APPLICATION_ENV || 'development' ==
APPLICATION_ENV) {
$profiler = new Zend_Db_Profiler_Firebug('All Database
Queries:');
$profiler->setEnabled(true);
$db->getDbAdapter()->setProfiler($profiler);
}

Zend_Db_Table_Abstract::setDefaultAdapter($db->getDbAdapter());
return $db;
}
}

index.php is more or less default..

The question is: is there any way to use Zend_Application_Bootstrap and all
this classes to easily setup autoload, db, models for command line interface
so I can run cronjob easily?

Regards,
Saša Stamenković


[fw-general] Setup environment for cronjob

2009-05-26 Thread umpirsky

Hi to all.

I have Zend framework app created by Zend Tool, with default project
structure (1.8). I use models, and my library, everithing is set up,
autoload.. My bootstrap file:

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
protected function _initAutoload() {
return new Zend_Application_Module_Autoloader(array(
'namespace' => 'Default_',
'basePath'  => dirname(__FILE__),
));
}
protected function _initDb() {
$db = $this->getPluginResource('db');

// Debug SQL
if ('testing' == APPLICATION_ENV || 'development' ==
APPLICATION_ENV) {
$profiler = new Zend_Db_Profiler_Firebug('All Database
Queries:');
$profiler->setEnabled(true);
$db->getDbAdapter()->setProfiler($profiler);
}

Zend_Db_Table_Abstract::setDefaultAdapter($db->getDbAdapter());
return $db;
}
}

index.php is more or less default..

The question is: is there any way to use Zend_Application_Bootstrap and all
this classes to easily setup autoload, db, models for command line interface
so I can run cronjob easily?

Regards,
Saša Stamenković
-- 
View this message in context: 
http://www.nabble.com/Setup-environment-for-cronjob-tp23719572p23719572.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Setup environment for cronjob

2009-05-26 Thread Jurian Sluiman
Op Tuesday 26 May 2009 11:21:45 schreef umpirsky:
> Hi to all.
>
> I have Zend framework app created by Zend Tool, with default project
> structure (1.8). I use models, and my library, everithing is set up,
> autoload.. My bootstrap file:
>
> class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
> protected function _initAutoload() {
> return new Zend_Application_Module_Autoloader(array(
> 'namespace' => 'Default_',
> 'basePath'  => dirname(__FILE__),
> ));
> }
> protected function _initDb() {
> $db = $this->getPluginResource('db');
>
> // Debug SQL
> if ('testing' == APPLICATION_ENV || 'development' ==
> APPLICATION_ENV) {
> $profiler = new Zend_Db_Profiler_Firebug('All Database
> Queries:');
> $profiler->setEnabled(true);
> $db->getDbAdapter()->setProfiler($profiler);
> }
>
> Zend_Db_Table_Abstract::setDefaultAdapter($db->getDbAdapter());
> return $db;
> }
> }
>
> index.php is more or less default..
>
> The question is: is there any way to use Zend_Application_Bootstrap and all
> this classes to easily setup autoload, db, models for command line
> interface so I can run cronjob easily?
>
> Regards,
> Saša Stamenković

What about a cron.php which instantiates the Zend_Application like index.php. 
You boostrap the application, but before running you configure the router to 
execute only a specific module/controller/action. This configuration could be 
a variety of options (directly, through an additional controller plugin, or 
maybe an application resource).

Regards, Jurian
--
Jurian Sluiman
Soflomo.com


Re: [fw-general] Setup environment for cronjob

2009-05-26 Thread umpirsky

Hi, thanks for the reply, that was exactly what I wanted to do, use
Zend_application. But I don't have custom routes in my ini file, so, I guess
I don't have to care about routes, I just need db and autoload.

BTW, in my index.php I have set fallback loader, I have Zend Framework in my
include path, somewhere on the server, I have my library in /lib/Umpirsky,
all that is loaded with fallback loader, how can I autoload them in
Bootstrap class with this new autoloader, not to use fallback?

Regards,
Sasa Stamenkovic.



Jurian Sluiman wrote:
> 
> Op Tuesday 26 May 2009 11:21:45 schreef umpirsky:
>> Hi to all.
>>
>> I have Zend framework app created by Zend Tool, with default project
>> structure (1.8). I use models, and my library, everithing is set up,
>> autoload.. My bootstrap file:
>>
>> class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {
>> protected function _initAutoload() {
>> return new Zend_Application_Module_Autoloader(array(
>> 'namespace' => 'Default_',
>> 'basePath'  => dirname(__FILE__),
>> ));
>> }
>> protected function _initDb() {
>> $db = $this->getPluginResource('db');
>>
>> // Debug SQL
>> if ('testing' == APPLICATION_ENV || 'development' ==
>> APPLICATION_ENV) {
>> $profiler = new Zend_Db_Profiler_Firebug('All Database
>> Queries:');
>> $profiler->setEnabled(true);
>> $db->getDbAdapter()->setProfiler($profiler);
>> }
>>
>> Zend_Db_Table_Abstract::setDefaultAdapter($db->getDbAdapter());
>> return $db;
>> }
>> }
>>
>> index.php is more or less default..
>>
>> The question is: is there any way to use Zend_Application_Bootstrap and
>> all
>> this classes to easily setup autoload, db, models for command line
>> interface so I can run cronjob easily?
>>
>> Regards,
>> Saša Stamenković
> 
> What about a cron.php which instantiates the Zend_Application like
> index.php. 
> You boostrap the application, but before running you configure the router
> to 
> execute only a specific module/controller/action. This configuration could
> be 
> a variety of options (directly, through an additional controller plugin,
> or 
> maybe an application resource).
> 
> Regards, Jurian
> --
> Jurian Sluiman
> Soflomo.com
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Setup-environment-for-cronjob-tp23719572p23721719.html
Sent from the Zend Framework mailing list archive at Nabble.com.