Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 495949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:38:23+00:00 2026-05-13T05:38:23+00:00

I am using Zend Framework 1.9.6. I want to start using cron jobs. I

  • 0

I am using Zend Framework 1.9.6. I want to start using cron jobs. I am new to this so I’m not quite sure how to do this.

I’m thinking it would be a good idea to store my crons in /myapp/scripts or /myapp/application/cronjobs. What do you think? (my application only has a default module)

Once I’ve decided on a place to store them, how would I go about creating a script? Let’s say that I want to access a database, check for changes, and send an email as a report. I would need to use some Zend_Db components, and Zend_Mail components, as well as read the default config values. I guess I might even want to Bootstrap the application? But I won’t need any views so I don’t know if that would be the best idea. I don’t know. What should I do, and how can I do it? Again, I am using version 1.9.6 and created my application with the Zend_Tool command-line script.

I think there’s enough information online about how to add the cron job to the crontab file. (My web host also offers a tool to make this really easy, so I’m not so much interested in this part).

Have you done this in a 1.8+ application? Do you have an example script you could share?

Solution

Since posting this question, I have started a new job and become more comfortable working with Zend Framework. Here’s what we’ve been doing at the company I now work for. I’m not saying this is a best practice, or ideal, but this information may be helpful to someone.

  • Create a top level bin directory to store all command line scripts.
  • Create a "CLI bootstrap" file that can be included in any command line scripts which will bootstrap the application so that you have easy access to your models just like you would if you were working with a controller.
  • All of our cron job scripts live in the bin directory so they are not publicly accessible. Also, since they are command line scripts, they do not make use of controllers or views. They are mostly simple little procedural scripts. Our cron jobs are managed manually, so we don’t always remember which cron jobs we have scheduled to run.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T05:38:24+00:00Added an answer on May 13, 2026 at 5:38 am

    I found it easiest to have the exact same configuration as my main site by having a function that created the application shared across all cronjobs and the site.

    I did it this way as although there is probably quite a bit more overhead, it didn’t matter as much (extra couple of milliseconds on a cronjob are nothing) and as the setup was exactly the same I never ran into any issues using shared code. For example, add database config is in exactly the same place, and if I added another namespace (as you can see I have done), I could do it globally.
    The one thing that you could consider doing is using a different bootstrapper, which would reduce the cost as you don’t bootstrap the views (which the cron jobs have no need for)

    My setup function is (called by cronjobs and the main application):

    function createApplication() {
        require_once 'Zend/Application.php';
        $application = new Zend_Application(
                APPLICATION_ENV,
                CONFIG_PATH . '/application.ini'
        );
        $application->bootstrap();
    
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('Search_');
    
        return $application;
    }
    

    So as mentioned, in my cronjobs, I don’t call $application->run()

    However, as mentioned, you could use diffrent bootstraps for the cronjobs to avoid setting up the views. Before $application->bootstrap() is called, you need to call $application->setBootstrap()

     /*
      * @param $path the path to Bootstrap.php, if not set it will default to the 
      *             application bootstrap
      * @return Zend_Application
      */
    function createApplication($path = null) {
        require_once 'Zend/Application.php';
        $application = new Zend_Application(
                APPLICATION_ENV,
                CONFIG_PATH . '/application.ini'
        );
    
        if ( $path ){
            $application->setBootstrap($path);
        }
        $application->bootstrap();
    
        $autoloader = Zend_Loader_Autoloader::getInstance();
        $autoloader->registerNamespace('Search_');
    
        return $application;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using doctrine 2.1 (and zend framework 1.11, not that it matters for this matter),
I want to get the out parameter of stored procedure using Zend framework Here's
I want to write a worker for beanstalkd in php, using a Zend Framework
I'm using Zend Framework for PHP and handling sessions with the Zend_Session module. This
I want to write a php application using Zend Framework 2 (just the beta
I am using zend framework on windows. I want to implement ajax in my
Hi I want to parse an excel file using zend framework. I went to
I want to imitate the following SOAP request using Zend Framework but I don't
I am using Zend Framework. For a particular form, there is not enough space
Note: I'm using Zend Framework, but I think most of this applies to PHP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.