{"id":420,"date":"2014-07-12T19:22:01","date_gmt":"2014-07-12T18:22:01","guid":{"rendered":"http:\/\/louis.hatier.me\/blog\/?p=420"},"modified":"2015-08-12T17:30:37","modified_gmt":"2015-08-12T16:30:37","slug":"taches-cron-zend","status":"publish","type":"post","link":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/","title":{"rendered":"T\u00e2ches Cron avec Zend"},"content":{"rendered":"<p><a title=\"\" href=\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg\" data-rel=\"lightbox-gallery-Kwxtbbxe\" data-rl_title=\"\" data-rl_caption=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-315 alignleft\" title=\"Logo Zend Framework\" src=\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg\" alt=\"Logo Zend Framework\" width=\"237\" height=\"55\" \/><\/a>Au sein d\u2019un projet Zend Framework, il peut \u00eatre utile qu\u2019un script ind\u00e9pendant puisse profiter des fonctionnalit\u00e9s de ZF, et des classes\/templates qui y sont charg\u00e9s.<\/p>\n<p>Voici un exemple de script PHP utilis\u00e9 comme t\u00e2che Cron.<\/p>\n<p><!--more--><\/p>\n<p>Fichier <code>BootstrapCron.php<\/code> qui sera inclue par le script :<\/p>\n<pre><code class=\"\u201dphp\u201d\">mb_internal_encoding('utf-8');\r\nmb_regex_encoding('utf-8');\r\nsetlocale(LC_ALL, 'fr_FR.utf8');\r\n\r\n\/\/ Define path to application directory\r\ndefined('APPLICATION_PATH')\r\n    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '\/..'));\r\n\r\n\/\/ Define path to library directory\r\ndefined('LIBRARY_PATH')\r\n    || define('LIBRARY_PATH', realpath(dirname(__FILE__) . '\/..\/..\/library'));\r\n\r\n\/\/ Define path to public directory\r\ndefined('PUBLIC_PATH')\r\n    || define('PUBLIC_PATH', realpath(dirname(__FILE__) . '\/..\/..\/public'));\r\n\r\ndefine('APPLICATION_ENV','development');\r\n\r\n\/\/ Ensure library is on include_path\r\nset_include_path(implode(PATH_SEPARATOR, array(\r\n    realpath(LIBRARY_PATH),\r\n    realpath(APPLICATION_PATH),\r\n    realpath(APPLICATION_PATH . '\/models'),\r\n    get_include_path(),\r\n)));\r\n\r\nrequire_once 'Zend\/Loader\/Autoloader.php';\r\n$autoloader = Zend_Loader_Autoloader::getInstance();\r\n\/\/ custom classes\r\n$autoloader-&gt;registerNamespace('Util_');\r\n\r\nrequire_once 'Zend\/Application.php';\r\n$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '\/configs\/application.ini');\r\n$application-&gt;bootstrap();\r\n\r\n$view = new Zend_View();\r\n$view-&gt;setScriptPath(APPLICATION_PATH . '\/views\/scripts\/');\r\n<\/code><\/pre>\n<p>Le script en question :<\/p>\n<pre><code class=\"\u201dphp\u201d\">require_once 'BootstrapCron.php';\r\n\r\n$tableUser = new Table_User();\r\n$view-&gt;user = $tableUser-&gt;get(1);\r\n$content = $view-&gt;render('user\/profile.phtml');\r\n\u2026\r\n<\/code><\/pre>\n<div style=\"padding-bottom:20px; padding-top:10px;\" class=\"hupso-share-buttons\"><!-- Hupso Share Buttons - https:\/\/www.hupso.com\/share\/ --><a class=\"hupso_counters\" href=\"https:\/\/www.hupso.com\/share\/\"><img decoding=\"async\" src=\"https:\/\/static.hupso.com\/share\/buttons\/dot.png\" style=\"border:0px; padding-top:2px; float:left;\" alt=\"Share Button\"\/><\/a><script type=\"text\/javascript\">var hupso_services_c=new Array(\"twitter\",\"facebook_like\",\"pinterest\",\"email\",\"linkedin\");var hupso_counters_lang = \"en_US\";var hupso_image_folder_url = \"\";var hupso_url_c=\"\";var hupso_title_c=\"T%C3%A2ches%20Cron%20avec%20Zend\";<\/script><script type=\"text\/javascript\" src=\"https:\/\/static.hupso.com\/share\/js\/counters.js\"><\/script><!-- Hupso Share Buttons --><\/div>","protected":false},"excerpt":{"rendered":"<p>Au sein d\u2019un projet Zend Framework, il peut \u00eatre utile qu\u2019un script ind\u00e9pendant puisse profiter des fonctionnalit\u00e9s de ZF, et des classes\/templates qui y sont charg\u00e9s. Voici un exemple de script PHP utilis\u00e9 comme t\u00e2che Cron.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[57,17],"class_list":["post-420","post","type-post","status-publish","format-standard","hentry","category-php","tag-php","tag-zend"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>T\u00e2ches Cron avec Zend - Melting Poutre<\/title>\n<meta name=\"description\" content=\"Exemple de script Cron utilisant le Zend Framework\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/\" \/>\n<meta property=\"og:locale\" content=\"fr_FR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"T\u00e2ches Cron avec Zend - Melting Poutre\" \/>\n<meta property=\"og:description\" content=\"Exemple de script Cron utilisant le Zend Framework\" \/>\n<meta property=\"og:url\" content=\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/\" \/>\n<meta property=\"og:site_name\" content=\"Melting Poutre\" \/>\n<meta property=\"article:published_time\" content=\"2014-07-12T18:22:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2015-08-12T16:30:37+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg\" \/>\n<meta name=\"author\" content=\"Louis Hatier\" \/>\n<meta name=\"twitter:label1\" content=\"\u00c9crit par\" \/>\n\t<meta name=\"twitter:data1\" content=\"Louis Hatier\" \/>\n\t<meta name=\"twitter:label2\" content=\"Dur\u00e9e de lecture estim\u00e9e\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/\"},\"author\":{\"name\":\"Louis Hatier\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\"},\"headline\":\"T\u00e2ches Cron avec Zend\",\"datePublished\":\"2014-07-12T18:22:01+00:00\",\"dateModified\":\"2015-08-12T16:30:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/\"},\"wordCount\":59,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\"},\"image\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg\",\"keywords\":[\"PHP\",\"Zend\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/\",\"url\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/\",\"name\":\"T\u00e2ches Cron avec Zend - Melting Poutre\",\"isPartOf\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg\",\"datePublished\":\"2014-07-12T18:22:01+00:00\",\"dateModified\":\"2015-08-12T16:30:37+00:00\",\"description\":\"Exemple de script Cron utilisant le Zend Framework\",\"inLanguage\":\"fr-FR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage\",\"url\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg\",\"contentUrl\":\"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg\"},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/#website\",\"url\":\"https:\/\/louis.hatier.me\/blog\/\",\"name\":\"Melting Poutre\",\"description\":\"Du web et d&#039;autres choses\",\"publisher\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/louis.hatier.me\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"fr-FR\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11\",\"name\":\"Louis Hatier\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"fr-FR\",\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g\",\"caption\":\"Louis Hatier\"},\"logo\":{\"@id\":\"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/louis.hatier.me\",\"https:\/\/www.linkedin.com\/in\/louishatier\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"T\u00e2ches Cron avec Zend - Melting Poutre","description":"Exemple de script Cron utilisant le Zend Framework","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/","og_locale":"fr_FR","og_type":"article","og_title":"T\u00e2ches Cron avec Zend - Melting Poutre","og_description":"Exemple de script Cron utilisant le Zend Framework","og_url":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/","og_site_name":"Melting Poutre","article_published_time":"2014-07-12T18:22:01+00:00","article_modified_time":"2015-08-12T16:30:37+00:00","og_image":[{"url":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg","type":"","width":"","height":""}],"author":"Louis Hatier","twitter_misc":{"\u00c9crit par":"Louis Hatier","Dur\u00e9e de lecture estim\u00e9e":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#article","isPartOf":{"@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/"},"author":{"name":"Louis Hatier","@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11"},"headline":"T\u00e2ches Cron avec Zend","datePublished":"2014-07-12T18:22:01+00:00","dateModified":"2015-08-12T16:30:37+00:00","mainEntityOfPage":{"@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/"},"wordCount":59,"commentCount":0,"publisher":{"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11"},"image":{"@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage"},"thumbnailUrl":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg","keywords":["PHP","Zend"],"articleSection":["PHP"],"inLanguage":"fr-FR","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/","url":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/","name":"T\u00e2ches Cron avec Zend - Melting Poutre","isPartOf":{"@id":"https:\/\/louis.hatier.me\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage"},"image":{"@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage"},"thumbnailUrl":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg","datePublished":"2014-07-12T18:22:01+00:00","dateModified":"2015-08-12T16:30:37+00:00","description":"Exemple de script Cron utilisant le Zend Framework","inLanguage":"fr-FR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/"]}]},{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/louis.hatier.me\/blog\/taches-cron-zend\/#primaryimage","url":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg","contentUrl":"http:\/\/louis.hatier.me\/blog\/wp-content\/uploads\/2014\/02\/logo-zend-framework.jpg"},{"@type":"WebSite","@id":"https:\/\/louis.hatier.me\/blog\/#website","url":"https:\/\/louis.hatier.me\/blog\/","name":"Melting Poutre","description":"Du web et d&#039;autres choses","publisher":{"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/louis.hatier.me\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"fr-FR"},{"@type":["Person","Organization"],"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/2f200d0368def135b452e65491c4dd11","name":"Louis Hatier","image":{"@type":"ImageObject","inLanguage":"fr-FR","@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd8d107ede5a4ec340326655e74a00ca62b02e41a02442f961c36f085aa89942?s=96&d=mm&r=g","caption":"Louis Hatier"},"logo":{"@id":"https:\/\/louis.hatier.me\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/louis.hatier.me","https:\/\/www.linkedin.com\/in\/louishatier\/"]}]}},"_links":{"self":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts\/420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/comments?post=420"}],"version-history":[{"count":6,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts\/420\/revisions"}],"predecessor-version":[{"id":724,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/posts\/420\/revisions\/724"}],"wp:attachment":[{"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/media?parent=420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/categories?post=420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/louis.hatier.me\/blog\/wp-json\/wp\/v2\/tags?post=420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}