SlideShare une entreprise Scribd logo
1  sur  55
Télécharger pour lire hors ligne
SCHEDULER & CLI 
Krystian Szymukowicz 
k.szymukowicz@sourcebroker.net
PRESENTATION ROADMAP 
WHAT IS SCHEDULER? 
SCHEDULER FOR USERS 
SCHEDULER FOR DEVELOPERS 
WHAT IS CLI? 
CLI FOR USERS 
CLI FOR DEVELOPER 
INTERESTING EXTENSIONS 
https://github.com/t33k/schedulerX 
Krystian Szymukowicz 
k.szymukowicz@sourcebroker.net
SCHEDULER 
module to set up and monitor recurring things
WHY DO WE NEED SCHEDULER? 
• system extensions and user extensions do not have to 
repeat the code 
• TYPO3 installation is better movable between hostings 
• gives overview of what scheduler jobs are there in system 
• gives overview of what jobs are currently active/running
SCHEDULER 
USER/INTEGRATOR PERSPECTIVE
NOT INSTALLED BY DEFAULT
SETTING SCHEDULER MAIN CRONJOB 
EDIT USERS CRONTABS. 
When logged to ssh console as www-data user: 
crontab -e 
*/15 * * * * php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler 
When logged to ssh console as root then probably better is to: 
su www-data -c”crontab -e” 
*/15 * * * * php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler 
EDIT SYSTEM WIDE CRONTABS. 
Go to /etc/cron.d/ and create file 
*/15 * * * * www-data php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler
SETTING SCHEDULER MAIN CRONJOB 
Different problems on limited ssh and shared hostings: 
• Fake cron to run just php script by calling Apache (no CLI) 
• Different PHP version for CLI (works from BE not form CLI) 
• php_memory limit low for CLI (works from BE not form CLI) 
• No way to see errors from CLI on shared hostings.
SETTING SCHEDULER MAIN CRONJOB 
General fake cron problem overcome: 
<php 
exec('/usr/local/php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler'); 
<php 
exec('/usr/local/php-cgi /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler'); 
Different hosting - different variations 
• Hoster - ALL-INKL 
<php 
exec('php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler'); 
AddHandler php5-cgi .php .phpsh 
/cron/cron.php 
/cron/.htaccess 
/fileadmin/ 
/typo3/ 
/typo3conf 
/etc…
SETTING SCHEDULER MAIN CRONJOB 
Be ready to fight for Scheduler cron! 
Google for: 
"typo3 cli_dispatch.phpsh [hoster name]" 
Do not hesitate to ask hoster admin!
SUCCESS
CRON FREQUENCY 
/etc/cron.d/ 
*/15 * * * * www-data php /var/www/workspace-typo3/projects/acme/typo3/cli_dispatch.phpsh scheduler 
10:00 10:15 10:30 10:45 
11:00 
21-11-14 10:10 
21-11-14 10:15 
5 10 15 20 25 35 40 50 55 
10:00 30 45 11:00 
Task with id=2 will be late by 10 minutes
SCHEDULER 
DEVELOPER PERSPECTIVE
SIMPLE EXT WITH SCHEDULER TASK 
! 
typo3conf/ext 
/Scheduler1 
https://github.com/t33k/scheduler1 
/Classes/Task/SimpleReportTask.php 
/ext_conf.php 
/ext_localconf.php
SIMPLE EXT WITH SCHEDULER TASK 
Register new extension: 
ext_conf.php 
<?php 
! 
$EM_CONF[$_EXTKEY] = array( 
'title' => 'Scheduler Test - The simplest extension with task', 
'constraints' => array(), 
); 
https://github.com/t33k/scheduler1
SIMPLE EXT WITH SCHEDULER TASK 
Register new scheduler task: 
ext_localconf.php 
<?php 
! 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'] 
['VScheduler1TaskSampleTask'] = array( 
'extension' => $_EXTKEY, 
'title' => 'The simplest task ever', 
'description' => 'Task description' 
); 
https://github.com/t33k/scheduler1
SIMPLE EXT WITH SCHEDULER TASK 
Class with task: 
Classes/Task/SampleTask.php 
<?php 
! 
namespace VScheduler1Task; 
class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask { 
! 
public function execute() { 
$success = FALSE; 
… 
… 
return $success; 
} 
! 
} 
https://github.com/t33k/scheduler1
SIMPLE EXT WITH SCHEDULER TASK II 
https://github.com/t33k/scheduler2 
getAdditonalInformation() 
getProgress() 
implements TYPO3CMSSchedulerProgressProviderInterface()
SIMPLE EXT WITH SCHEDULER TASK II 
Classes/Task/SampleTask.php 
<?php 
! 
namespace VScheduler2Task; 
! 
class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask 
implements TYPO3CMSSchedulerProgressProviderInterface { 
! 
public $email = 'dr_who@universe.thr'; 
! 
public function execute() { 
return TRUE; 
} 
! 
public function getAdditionalInformation() { 
return 'Time now: ' . strftime('%H:%m:%S', time()) . ', Next exec time: ' . 
strftime('%x', $this->getNextDueExecution()) . ', Email: ' . $this->email; 
} 
! 
public function getProgress(){ 
return rand(0,100); 
} 
! 
} 
https://github.com/t33k/scheduler2
SIMPLE EXT WITH SCHEDULER TASK III 
Flash messages and debug: 
System flash messages 
Standard scheduler task info 
GeneralUtility::devLog(….. 
debug(ArrayUtility::convertObjectToArray($this));
SIMPLE EXT WITH SCHEDULER TASK III 
Classes/Task/SampleTask.php 
<?php 
! 
namespace VScheduler3Task; 
use TYPO3CMSCoreUtilityGeneralUtility; 
use TYPO3CMSExtbaseUtilityArrayUtility; 
! 
class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask{ 
public function execute() { 
$flashMessageOk = GeneralUtility::makeInstance( 
'TYPO3CMSCoreMessagingFlashMessage', 
'Message to be passed', 
'OK Example', 
TYPO3CMSCoreMessagingFlashMessage::OK); 
$defaultFlashMessageQueue = $this->getDefaultFlashMessageQueue(); 
$defaultFlashMessageQueue->enqueue($flashMessageOk); 
! 
GeneralUtility::devLog('Message', 'scheduler3', 2, ArrayUtility::convertObjectToArray($this)); 
! 
debug(ArrayUtility::convertObjectToArray($this)); 
return TRUE; 
} 
! 
} 
https://github.com/t33k/scheduler3
SIMPLE EXT WITH SCHEDULER TASK IV 
Additional field https://github.com/t33k/scheduler4
SIMPLE EXT WITH SCHEDULER TASK IV 
Additional field 
ext_localconf.php 
Classes/Task/SampleTaskAdditionalFieldProvider.php 
! 
class SampleTaskAdditionalFieldProvider implements TYPO3CMSSchedulerAdditionalFieldProviderInterface{ 
! 
public function getAdditionalFields 
(array &$taskInfo, $task, TYPO3CMSSchedulerControllerSchedulerModuleController $parentObject) {…} 
! 
public function validateAdditionalFields 
(array &$submittedData, TYPO3CMSSchedulerControllerSchedulerModuleController $parentObject) {…} 
! 
public function saveAdditionalFields 
(array $submittedData, TYPO3CMSSchedulerTaskAbstractTask $task) {…} 
} 
https://github.com/t33k/scheduler4 
<?php 
! 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['VScheduler4TaskSampleTask'] = 
array( 
'extension' => $_EXTKEY, 
'title' => 'Scheduler4 test - example for new field', 
'description' => 'How to add new field to scheduler task.', 
'additionalFields' => 'VScheduler4TaskSampleTaskAdditionalFieldProvider' 
);
SIMPLE EXT WITH SCHEDULER TASK V 
Create new tasks automatically in FE and BE 
https://github.com/t33k/scheduler5 
Classes/Task/SampleTask.php 
<?php 
! 
namespace VScheduler5Task; 
use TYPO3CMSCoreUtilityGeneralUtility; 
! 
class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask { 
! 
public function execute() { 
/** @var $newTask VScheduler5TaskSampleTask */ 
$newTask = GeneralUtility::makeInstance('VScheduler5TaskSampleTask'); 
$newTask->setDescription('Task description'); 
$newTask->setTaskGroup(0); 
$newTask->registerRecurringExecution($start = time(), $interval = 86400, $end = 0, 
$multiple = FALSE, $cron_cmd = ''); 
$newTask->email = 'test.drwho+' . rand(0,10) . '@gmail.com'; 
! 
/** @var TYPO3CMSSchedulerScheduler $scheduler */ 
$scheduler = GeneralUtility::makeInstance("TYPO3CMSSchedulerScheduler"); 
$scheduler->addTask($newTask); 
! 
return TRUE; 
} 
! 
public function getAdditionalInformation() { 
return 'Email:' . $this->email; 
} 
! 
}
SIMPLE EXT WITH SCHEDULER TASK VII 
Autmaticaly disable task 
Classes/Task/SampleTask.php 
<?php 
! 
namespace VScheduler7Task; 
! 
class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask { 
! 
public $counter = 10; 
! 
public function execute() { 
$this->counter = $this->counter - 1; 
if ($this->counter === 0) { 
// $this->remove(); 
$this->setDisabled(TRUE); 
} 
$this->save(); 
return TRUE; 
} 
! 
public function getAdditionalInformation() { 
return $this->counter; 
} 
! 
}
THINGS TO REMEMBER 
Object is serialized once on creation of scheduler task so all 
future changes to methods or properties can lead to errors. 
The solution then is to delete the scheduler task and create 
new one.
CLI 
USER PERSPECTIVE
CLI 
Command Line Interface 
! 
One of SAPI the PHP interact with different env - here with 
shell. Others SAPI examples: CGI, fpm , apache2handler 
CLI points: 
• No execution time limit by default. 
• No headers are send. 
• No path is changed while running by default
CLI Command Line Interface 
php typo3/cli_dispatch.phpsh
lowlevel_admin setBElock
lowlevel_cleaner [option] -r
lowlevel_refindex
extbase
CLI 
DEVELOPER PERSPECTIVE
EXTBASE COMMAND CENTER 
Backport from TYPO3 FLOW 
$ php cli_dispatch.phpsh extbase <command identifier> --argumentName=value 
$ php cli_dispatch.phpsh extbase scheduler6:sample:second --name=adam --number=12 --enabled 
This will call: 
—> extension scheduler6 
—> class SampleCommandController 
—> method secondCommand 
typo3conf/ext/scheduler6/Classes/Command/SampleCommandController.php 
secondCommand($name, $number, $enabled = true)
ext_localconf.php 
<?php 
! 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'VScheduler6Command 
SampleCommandController'; 
typo3conf/ext/scheduler6/Classes/Command/SampleCommandController.php 
/** 
* Class SampleCommandController 
* @package VScheduler6Command 
*/ 
class SampleCommandController extends TYPO3CMSExtbaseMvcControllerCommandController { ! 
/** 
* Get Faq title for given uid 
* 
* This text goes into description of CLI 
* so you see when you will do php typo3/cli_dispatch.phpsh extbase help scheduler6:sample:newsTitle. 
* Second line of description. 
* Third line of description. 
* 
* @param integer $faqUid Faq uid 
* @return void 
*/ 
public function faqTitleCommand($faqUid) { 
$faqUid = intval($faqUid); 
if ($faqUid) { 
$faqRepository = $this->getFaqRepository(); 
$faq = $faqRepository->findByUid($faqUid); 
if(NULL !== $faq){ 
$this->outputLine($faq->getQuestion()); 
} 
} 
}
php typo3/cli_dispatch.phpsh extbase help scheduler6:sample:faqTitle 
All texts are taken from class comment / arguments !!!
EXTBASE COMMAND CENTER 
ext_localconf.php 
<?php 
! 
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'VScheduler6Command 
SampleCommandController'; 
typo3conf/ext/scheduler6/Classes/Command/SampleCommandController.php 
/** 
* Class SampleCommandController 
* @package VScheduler6Command 
*/ 
class SampleCommandController extends TYPO3CMSExtbaseMvcControllerCommandController { ! 
/** 
* Get Faq title for given uid 
* 
* This text goes into description of CLI 
* so you see when you will do php typo3/cli_dispatch.phpsh extbase help scheduler6:sample:newsTitle. 
* Second line of description. 
* Third line of description. 
* 
* @param integer $faqUid Faq uid 
* @return void 
*/ 
public function faqTitleCommand($faqUid) { 
$faqUid = intval($faqUid); 
if ($faqUid) { 
$faqRepository = $this->getFaqRepository(); 
$faq = $faqRepository->findByUid($faqUid); 
if(NULL !== $faq){ 
$this->outputLine($faq->getQuestion()); 
} 
} 
}
EXTBASE COMMAND CENTER
SCHEDULER/CLI 
INTERESTING EXTENSIONS
CLEARTYPO3CACHE 
$ php cli_dispatch.phpsh cleartypo3cache all 
$ php cli_dispatch.phpsh cleartypo3cache pages 
https://github.com/t33k/cleartypo3cache 
$ php cli_dispatch.phpsh cleartypo3cache system 
Create BE user "_cli_cleartypo3cache" with TS settings 
options.clearCache.all=1 
options.clearCache.pages=1 
options.clearCache.system=1
CLEARTYPO3CACHE https://github.com/t33k/cleartypo3cache
T3DEPLOY 
https://github.com/AOEmedia/t3deploy 
Update only (more safe) 
php typo3/cli_dispatch.phpsh t3deploy database updateStructure --verbose --execute 
Remove also 
php typo3/cli_dispatch.phpsh t3deploy database updateStructure --remove --verbose --execute
THANK YOU! 
Krystian Szymukowicz 
k.szymukowicz@sourcebroker.net

Contenu connexe

Tendances

Teste Tradicional e Teste Ágil: de que lado você esta?
Teste Tradicional e Teste Ágil: de que lado você esta?Teste Tradicional e Teste Ágil: de que lado você esta?
Teste Tradicional e Teste Ágil: de que lado você esta?Danilo Sousa
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytestSuraj Deshmukh
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesDerek Smith
 
Using GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to AzureUsing GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to AzureKasun Kodagoda
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium Zoe Gilbert
 
Regression testing
Regression testingRegression testing
Regression testingHarsh verma
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration TestingDavid Berliner
 
Mock objects - Teste de código com dependências
Mock objects - Teste de código com dependênciasMock objects - Teste de código com dependências
Mock objects - Teste de código com dependênciasDenis L Presciliano
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answerskavinilavuG
 
Cypress e2e automation testing - day1 intor by: Hassan Hameed
Cypress e2e automation testing -  day1 intor by: Hassan HameedCypress e2e automation testing -  day1 intor by: Hassan Hameed
Cypress e2e automation testing - day1 intor by: Hassan HameedHassan Muhammad
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...Edureka!
 
Unit testing framework
Unit testing frameworkUnit testing framework
Unit testing frameworkIgor Vavrish
 
Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Zhe Li
 
ITエンジニアのためのゼロから始める英語勉強法
ITエンジニアのためのゼロから始める英語勉強法ITエンジニアのためのゼロから始める英語勉強法
ITエンジニアのためのゼロから始める英語勉強法Tsuyoshi Ushio
 
Introdução a Testes Automatizados
Introdução a Testes AutomatizadosIntrodução a Testes Automatizados
Introdução a Testes Automatizadoselliando dias
 

Tendances (20)

Teste Tradicional e Teste Ágil: de que lado você esta?
Teste Tradicional e Teste Ágil: de que lado você esta?Teste Tradicional e Teste Ágil: de que lado você esta?
Teste Tradicional e Teste Ágil: de que lado você esta?
 
Python testing using mock and pytest
Python testing using mock and pytestPython testing using mock and pytest
Python testing using mock and pytest
 
Testing Tools
Testing ToolsTesting Tools
Testing Tools
 
Jest
JestJest
Jest
 
Unit Testing Concepts and Best Practices
Unit Testing Concepts and Best PracticesUnit Testing Concepts and Best Practices
Unit Testing Concepts and Best Practices
 
Using GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to AzureUsing GitHub Actions to Deploy your Workloads to Azure
Using GitHub Actions to Deploy your Workloads to Azure
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Regression testing
Regression testingRegression testing
Regression testing
 
Unit and integration Testing
Unit and integration TestingUnit and integration Testing
Unit and integration Testing
 
Mock objects - Teste de código com dependências
Mock objects - Teste de código com dependênciasMock objects - Teste de código com dependências
Mock objects - Teste de código com dependências
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answers
 
Cypress e2e automation testing - day1 intor by: Hassan Hameed
Cypress e2e automation testing -  day1 intor by: Hassan HameedCypress e2e automation testing -  day1 intor by: Hassan Hameed
Cypress e2e automation testing - day1 intor by: Hassan Hameed
 
Selenium Handbook
Selenium HandbookSelenium Handbook
Selenium Handbook
 
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...JavaScript Interview Questions and Answers | Full Stack Web Development Train...
JavaScript Interview Questions and Answers | Full Stack Web Development Train...
 
Unit testing framework
Unit testing frameworkUnit testing framework
Unit testing framework
 
Introduction to Robot Framework (external)
Introduction to Robot Framework (external)Introduction to Robot Framework (external)
Introduction to Robot Framework (external)
 
Test Automation Pyramid
Test Automation PyramidTest Automation Pyramid
Test Automation Pyramid
 
ITエンジニアのためのゼロから始める英語勉強法
ITエンジニアのためのゼロから始める英語勉強法ITエンジニアのためのゼロから始める英語勉強法
ITエンジニアのためのゼロから始める英語勉強法
 
Introdução a Testes Automatizados
Introdução a Testes AutomatizadosIntrodução a Testes Automatizados
Introdução a Testes Automatizados
 

En vedette

TYPO3 - optymalizacja pracy z instancjami
TYPO3 - optymalizacja pracy z instancjamiTYPO3 - optymalizacja pracy z instancjami
TYPO3 - optymalizacja pracy z instancjamiKrystian Szymukowicz
 
Insurance company - Andrina
Insurance company - AndrinaInsurance company - Andrina
Insurance company - Andrinaastoeckling
 
Redaccion de textos
Redaccion de textosRedaccion de textos
Redaccion de textosMelanie Rico
 
Northware - AX Services and Support - LITE
Northware - AX Services and Support - LITENorthware - AX Services and Support - LITE
Northware - AX Services and Support - LITEImre Szenttornyay, MSc.
 
Clini cast datapalooza presentation (1)
Clini cast  datapalooza presentation (1)Clini cast  datapalooza presentation (1)
Clini cast datapalooza presentation (1)Jack Challis
 
286.fiestas navideñas
286.fiestas navideñas286.fiestas navideñas
286.fiestas navideñasdec-admin
 
410. problemáticas que existen en el entorno
410. problemáticas que existen en el entorno410. problemáticas que existen en el entorno
410. problemáticas que existen en el entornodec-admin
 
Ciel mech webinar_sneakpeak
Ciel mech webinar_sneakpeakCiel mech webinar_sneakpeak
Ciel mech webinar_sneakpeakKamal Karimanal
 
Solids, Liquids and Gases
Solids, Liquids and GasesSolids, Liquids and Gases
Solids, Liquids and Gasesastoeckling
 
Market vision capabilities for goma - 083112 [final]
Market vision   capabilities for goma  - 083112 [final]Market vision   capabilities for goma  - 083112 [final]
Market vision capabilities for goma - 083112 [final]mvculture
 
Architecture portfolio mujahid habib
Architecture portfolio mujahid habibArchitecture portfolio mujahid habib
Architecture portfolio mujahid habibMUJAHID HABIB
 
71. el espacio del saber
71. el espacio del saber71. el espacio del saber
71. el espacio del saberdec-admin
 
427. ecoambiente
427. ecoambiente427. ecoambiente
427. ecoambientedec-admin
 
Redaccion de textos
Redaccion de textosRedaccion de textos
Redaccion de textosMelanie Rico
 

En vedette (20)

TYPO3 - optymalizacja pracy z instancjami
TYPO3 - optymalizacja pracy z instancjamiTYPO3 - optymalizacja pracy z instancjami
TYPO3 - optymalizacja pracy z instancjami
 
Insurance company - Andrina
Insurance company - AndrinaInsurance company - Andrina
Insurance company - Andrina
 
Recommended safer work practices for nursing
Recommended safer work practices for nursingRecommended safer work practices for nursing
Recommended safer work practices for nursing
 
Redaccion de textos
Redaccion de textosRedaccion de textos
Redaccion de textos
 
Very berry!
Very berry!Very berry!
Very berry!
 
Northware - AX Services and Support - LITE
Northware - AX Services and Support - LITENorthware - AX Services and Support - LITE
Northware - AX Services and Support - LITE
 
Clini cast datapalooza presentation (1)
Clini cast  datapalooza presentation (1)Clini cast  datapalooza presentation (1)
Clini cast datapalooza presentation (1)
 
286.fiestas navideñas
286.fiestas navideñas286.fiestas navideñas
286.fiestas navideñas
 
410. problemáticas que existen en el entorno
410. problemáticas que existen en el entorno410. problemáticas que existen en el entorno
410. problemáticas que existen en el entorno
 
Ciel mech webinar_sneakpeak
Ciel mech webinar_sneakpeakCiel mech webinar_sneakpeak
Ciel mech webinar_sneakpeak
 
Solids, Liquids and Gases
Solids, Liquids and GasesSolids, Liquids and Gases
Solids, Liquids and Gases
 
Market vision capabilities for goma - 083112 [final]
Market vision   capabilities for goma  - 083112 [final]Market vision   capabilities for goma  - 083112 [final]
Market vision capabilities for goma - 083112 [final]
 
Architecture portfolio mujahid habib
Architecture portfolio mujahid habibArchitecture portfolio mujahid habib
Architecture portfolio mujahid habib
 
Sección 5. infracciones de la vida silvestre
Sección 5. infracciones de la vida silvestreSección 5. infracciones de la vida silvestre
Sección 5. infracciones de la vida silvestre
 
71. el espacio del saber
71. el espacio del saber71. el espacio del saber
71. el espacio del saber
 
427. ecoambiente
427. ecoambiente427. ecoambiente
427. ecoambiente
 
Spinfinityrussian
SpinfinityrussianSpinfinityrussian
Spinfinityrussian
 
Redaccion de textos
Redaccion de textosRedaccion de textos
Redaccion de textos
 
Spinfinityrussian
SpinfinityrussianSpinfinityrussian
Spinfinityrussian
 
Sección 4. unidad 8
Sección 4. unidad 8Sección 4. unidad 8
Sección 4. unidad 8
 

Similaire à TYPO3 Scheduler

Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3kognate
 
Symfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeSymfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeOscar Merida
 
Introduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineBehzod Saidov
 
Codeigniter4の比較と検証
Codeigniter4の比較と検証Codeigniter4の比較と検証
Codeigniter4の比較と検証ME iBotch
 
Tools and Tips for Moodle Developers - #mootus16
 Tools and Tips for Moodle Developers - #mootus16 Tools and Tips for Moodle Developers - #mootus16
Tools and Tips for Moodle Developers - #mootus16Dan Poltawski
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90minsLarry Cai
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
DevOps in PHP environment
DevOps in PHP environment DevOps in PHP environment
DevOps in PHP environment Evaldo Felipe
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Pantheon
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applicationschartjes
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkBo-Yi Wu
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-TranslatorDashamir Hoxha
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction PresentationNerd Tzanetopoulos
 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnSandro Zaccarini
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionIan Barber
 
Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside OutFerenc Kovács
 

Similaire à TYPO3 Scheduler (20)

Catalyst MVC
Catalyst MVCCatalyst MVC
Catalyst MVC
 
Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3Server(less) Swift at SwiftCloudWorkshop 3
Server(less) Swift at SwiftCloudWorkshop 3
 
Symfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with easeSymfony console: build awesome command line scripts with ease
Symfony console: build awesome command line scripts with ease
 
Introduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command lineIntroduction to WP-CLI: Manage WordPress from the command line
Introduction to WP-CLI: Manage WordPress from the command line
 
Codeigniter4の比較と検証
Codeigniter4の比較と検証Codeigniter4の比較と検証
Codeigniter4の比較と検証
 
Tools and Tips for Moodle Developers - #mootus16
 Tools and Tips for Moodle Developers - #mootus16 Tools and Tips for Moodle Developers - #mootus16
Tools and Tips for Moodle Developers - #mootus16
 
Learn flask in 90mins
Learn flask in 90minsLearn flask in 90mins
Learn flask in 90mins
 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
DevOps in PHP environment
DevOps in PHP environment DevOps in PHP environment
DevOps in PHP environment
 
Introduction to Slurm
Introduction to SlurmIntroduction to Slurm
Introduction to Slurm
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
 
Building Testable PHP Applications
Building Testable PHP ApplicationsBuilding Testable PHP Applications
Building Testable PHP Applications
 
CodeIgniter PHP MVC Framework
CodeIgniter PHP MVC FrameworkCodeIgniter PHP MVC Framework
CodeIgniter PHP MVC Framework
 
Development Setup of B-Translator
Development Setup of B-TranslatorDevelopment Setup of B-Translator
Development Setup of B-Translator
 
Symfony2 Introduction Presentation
Symfony2 Introduction PresentationSymfony2 Introduction Presentation
Symfony2 Introduction Presentation
 
PHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vulnPHP Backdoor: The rise of the vuln
PHP Backdoor: The rise of the vuln
 
Debugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 VersionDebugging: Rules And Tools - PHPTek 11 Version
Debugging: Rules And Tools - PHPTek 11 Version
 
Php 5.6 From the Inside Out
Php 5.6 From the Inside OutPhp 5.6 From the Inside Out
Php 5.6 From the Inside Out
 

Dernier

Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleanscorenetworkseo
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书zdzoqco
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITMgdsc13
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书rnrncn29
 

Dernier (20)

Elevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New OrleansElevate Your Business with Our IT Expertise in New Orleans
Elevate Your Business with Our IT Expertise in New Orleans
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
办理多伦多大学毕业证成绩单|购买加拿大UTSG文凭证书
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
Git and Github workshop GDSC MLRITM
Git and Github  workshop GDSC MLRITMGit and Github  workshop GDSC MLRITM
Git and Github workshop GDSC MLRITM
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
『澳洲文凭』买詹姆士库克大学毕业证书成绩单办理澳洲JCU文凭学位证书
 
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
young call girls in Uttam Nagar🔝 9953056974 🔝 Delhi escort Service
 

TYPO3 Scheduler

  • 1. SCHEDULER & CLI Krystian Szymukowicz k.szymukowicz@sourcebroker.net
  • 2. PRESENTATION ROADMAP WHAT IS SCHEDULER? SCHEDULER FOR USERS SCHEDULER FOR DEVELOPERS WHAT IS CLI? CLI FOR USERS CLI FOR DEVELOPER INTERESTING EXTENSIONS https://github.com/t33k/schedulerX Krystian Szymukowicz k.szymukowicz@sourcebroker.net
  • 3. SCHEDULER module to set up and monitor recurring things
  • 4. WHY DO WE NEED SCHEDULER? • system extensions and user extensions do not have to repeat the code • TYPO3 installation is better movable between hostings • gives overview of what scheduler jobs are there in system • gives overview of what jobs are currently active/running
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. SETTING SCHEDULER MAIN CRONJOB EDIT USERS CRONTABS. When logged to ssh console as www-data user: crontab -e */15 * * * * php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler When logged to ssh console as root then probably better is to: su www-data -c”crontab -e” */15 * * * * php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler EDIT SYSTEM WIDE CRONTABS. Go to /etc/cron.d/ and create file */15 * * * * www-data php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler
  • 12. SETTING SCHEDULER MAIN CRONJOB Different problems on limited ssh and shared hostings: • Fake cron to run just php script by calling Apache (no CLI) • Different PHP version for CLI (works from BE not form CLI) • php_memory limit low for CLI (works from BE not form CLI) • No way to see errors from CLI on shared hostings.
  • 13. SETTING SCHEDULER MAIN CRONJOB General fake cron problem overcome: <php exec('/usr/local/php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler'); <php exec('/usr/local/php-cgi /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler'); Different hosting - different variations • Hoster - ALL-INKL <php exec('php /var/www/workspace-typo3/projects/62/typo3/cli_dispatch.phpsh scheduler'); AddHandler php5-cgi .php .phpsh /cron/cron.php /cron/.htaccess /fileadmin/ /typo3/ /typo3conf /etc…
  • 14. SETTING SCHEDULER MAIN CRONJOB Be ready to fight for Scheduler cron! Google for: "typo3 cli_dispatch.phpsh [hoster name]" Do not hesitate to ask hoster admin!
  • 16. CRON FREQUENCY /etc/cron.d/ */15 * * * * www-data php /var/www/workspace-typo3/projects/acme/typo3/cli_dispatch.phpsh scheduler 10:00 10:15 10:30 10:45 11:00 21-11-14 10:10 21-11-14 10:15 5 10 15 20 25 35 40 50 55 10:00 30 45 11:00 Task with id=2 will be late by 10 minutes
  • 17.
  • 18.
  • 19.
  • 21. SIMPLE EXT WITH SCHEDULER TASK ! typo3conf/ext /Scheduler1 https://github.com/t33k/scheduler1 /Classes/Task/SimpleReportTask.php /ext_conf.php /ext_localconf.php
  • 22. SIMPLE EXT WITH SCHEDULER TASK Register new extension: ext_conf.php <?php ! $EM_CONF[$_EXTKEY] = array( 'title' => 'Scheduler Test - The simplest extension with task', 'constraints' => array(), ); https://github.com/t33k/scheduler1
  • 23. SIMPLE EXT WITH SCHEDULER TASK Register new scheduler task: ext_localconf.php <?php ! $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'] ['VScheduler1TaskSampleTask'] = array( 'extension' => $_EXTKEY, 'title' => 'The simplest task ever', 'description' => 'Task description' ); https://github.com/t33k/scheduler1
  • 24. SIMPLE EXT WITH SCHEDULER TASK Class with task: Classes/Task/SampleTask.php <?php ! namespace VScheduler1Task; class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask { ! public function execute() { $success = FALSE; … … return $success; } ! } https://github.com/t33k/scheduler1
  • 25.
  • 26.
  • 27.
  • 28. SIMPLE EXT WITH SCHEDULER TASK II https://github.com/t33k/scheduler2 getAdditonalInformation() getProgress() implements TYPO3CMSSchedulerProgressProviderInterface()
  • 29. SIMPLE EXT WITH SCHEDULER TASK II Classes/Task/SampleTask.php <?php ! namespace VScheduler2Task; ! class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask implements TYPO3CMSSchedulerProgressProviderInterface { ! public $email = 'dr_who@universe.thr'; ! public function execute() { return TRUE; } ! public function getAdditionalInformation() { return 'Time now: ' . strftime('%H:%m:%S', time()) . ', Next exec time: ' . strftime('%x', $this->getNextDueExecution()) . ', Email: ' . $this->email; } ! public function getProgress(){ return rand(0,100); } ! } https://github.com/t33k/scheduler2
  • 30. SIMPLE EXT WITH SCHEDULER TASK III Flash messages and debug: System flash messages Standard scheduler task info GeneralUtility::devLog(….. debug(ArrayUtility::convertObjectToArray($this));
  • 31. SIMPLE EXT WITH SCHEDULER TASK III Classes/Task/SampleTask.php <?php ! namespace VScheduler3Task; use TYPO3CMSCoreUtilityGeneralUtility; use TYPO3CMSExtbaseUtilityArrayUtility; ! class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask{ public function execute() { $flashMessageOk = GeneralUtility::makeInstance( 'TYPO3CMSCoreMessagingFlashMessage', 'Message to be passed', 'OK Example', TYPO3CMSCoreMessagingFlashMessage::OK); $defaultFlashMessageQueue = $this->getDefaultFlashMessageQueue(); $defaultFlashMessageQueue->enqueue($flashMessageOk); ! GeneralUtility::devLog('Message', 'scheduler3', 2, ArrayUtility::convertObjectToArray($this)); ! debug(ArrayUtility::convertObjectToArray($this)); return TRUE; } ! } https://github.com/t33k/scheduler3
  • 32. SIMPLE EXT WITH SCHEDULER TASK IV Additional field https://github.com/t33k/scheduler4
  • 33. SIMPLE EXT WITH SCHEDULER TASK IV Additional field ext_localconf.php Classes/Task/SampleTaskAdditionalFieldProvider.php ! class SampleTaskAdditionalFieldProvider implements TYPO3CMSSchedulerAdditionalFieldProviderInterface{ ! public function getAdditionalFields (array &$taskInfo, $task, TYPO3CMSSchedulerControllerSchedulerModuleController $parentObject) {…} ! public function validateAdditionalFields (array &$submittedData, TYPO3CMSSchedulerControllerSchedulerModuleController $parentObject) {…} ! public function saveAdditionalFields (array $submittedData, TYPO3CMSSchedulerTaskAbstractTask $task) {…} } https://github.com/t33k/scheduler4 <?php ! $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks']['VScheduler4TaskSampleTask'] = array( 'extension' => $_EXTKEY, 'title' => 'Scheduler4 test - example for new field', 'description' => 'How to add new field to scheduler task.', 'additionalFields' => 'VScheduler4TaskSampleTaskAdditionalFieldProvider' );
  • 34. SIMPLE EXT WITH SCHEDULER TASK V Create new tasks automatically in FE and BE https://github.com/t33k/scheduler5 Classes/Task/SampleTask.php <?php ! namespace VScheduler5Task; use TYPO3CMSCoreUtilityGeneralUtility; ! class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask { ! public function execute() { /** @var $newTask VScheduler5TaskSampleTask */ $newTask = GeneralUtility::makeInstance('VScheduler5TaskSampleTask'); $newTask->setDescription('Task description'); $newTask->setTaskGroup(0); $newTask->registerRecurringExecution($start = time(), $interval = 86400, $end = 0, $multiple = FALSE, $cron_cmd = ''); $newTask->email = 'test.drwho+' . rand(0,10) . '@gmail.com'; ! /** @var TYPO3CMSSchedulerScheduler $scheduler */ $scheduler = GeneralUtility::makeInstance("TYPO3CMSSchedulerScheduler"); $scheduler->addTask($newTask); ! return TRUE; } ! public function getAdditionalInformation() { return 'Email:' . $this->email; } ! }
  • 35. SIMPLE EXT WITH SCHEDULER TASK VII Autmaticaly disable task Classes/Task/SampleTask.php <?php ! namespace VScheduler7Task; ! class SampleTask extends TYPO3CMSSchedulerTaskAbstractTask { ! public $counter = 10; ! public function execute() { $this->counter = $this->counter - 1; if ($this->counter === 0) { // $this->remove(); $this->setDisabled(TRUE); } $this->save(); return TRUE; } ! public function getAdditionalInformation() { return $this->counter; } ! }
  • 36. THINGS TO REMEMBER Object is serialized once on creation of scheduler task so all future changes to methods or properties can lead to errors. The solution then is to delete the scheduler task and create new one.
  • 38. CLI Command Line Interface ! One of SAPI the PHP interact with different env - here with shell. Others SAPI examples: CGI, fpm , apache2handler CLI points: • No execution time limit by default. • No headers are send. • No path is changed while running by default
  • 39. CLI Command Line Interface php typo3/cli_dispatch.phpsh
  • 45. EXTBASE COMMAND CENTER Backport from TYPO3 FLOW $ php cli_dispatch.phpsh extbase <command identifier> --argumentName=value $ php cli_dispatch.phpsh extbase scheduler6:sample:second --name=adam --number=12 --enabled This will call: —> extension scheduler6 —> class SampleCommandController —> method secondCommand typo3conf/ext/scheduler6/Classes/Command/SampleCommandController.php secondCommand($name, $number, $enabled = true)
  • 46. ext_localconf.php <?php ! $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'VScheduler6Command SampleCommandController'; typo3conf/ext/scheduler6/Classes/Command/SampleCommandController.php /** * Class SampleCommandController * @package VScheduler6Command */ class SampleCommandController extends TYPO3CMSExtbaseMvcControllerCommandController { ! /** * Get Faq title for given uid * * This text goes into description of CLI * so you see when you will do php typo3/cli_dispatch.phpsh extbase help scheduler6:sample:newsTitle. * Second line of description. * Third line of description. * * @param integer $faqUid Faq uid * @return void */ public function faqTitleCommand($faqUid) { $faqUid = intval($faqUid); if ($faqUid) { $faqRepository = $this->getFaqRepository(); $faq = $faqRepository->findByUid($faqUid); if(NULL !== $faq){ $this->outputLine($faq->getQuestion()); } } }
  • 47. php typo3/cli_dispatch.phpsh extbase help scheduler6:sample:faqTitle All texts are taken from class comment / arguments !!!
  • 48. EXTBASE COMMAND CENTER ext_localconf.php <?php ! $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'VScheduler6Command SampleCommandController'; typo3conf/ext/scheduler6/Classes/Command/SampleCommandController.php /** * Class SampleCommandController * @package VScheduler6Command */ class SampleCommandController extends TYPO3CMSExtbaseMvcControllerCommandController { ! /** * Get Faq title for given uid * * This text goes into description of CLI * so you see when you will do php typo3/cli_dispatch.phpsh extbase help scheduler6:sample:newsTitle. * Second line of description. * Third line of description. * * @param integer $faqUid Faq uid * @return void */ public function faqTitleCommand($faqUid) { $faqUid = intval($faqUid); if ($faqUid) { $faqRepository = $this->getFaqRepository(); $faq = $faqRepository->findByUid($faqUid); if(NULL !== $faq){ $this->outputLine($faq->getQuestion()); } } }
  • 49.
  • 52. CLEARTYPO3CACHE $ php cli_dispatch.phpsh cleartypo3cache all $ php cli_dispatch.phpsh cleartypo3cache pages https://github.com/t33k/cleartypo3cache $ php cli_dispatch.phpsh cleartypo3cache system Create BE user "_cli_cleartypo3cache" with TS settings options.clearCache.all=1 options.clearCache.pages=1 options.clearCache.system=1
  • 54. T3DEPLOY https://github.com/AOEmedia/t3deploy Update only (more safe) php typo3/cli_dispatch.phpsh t3deploy database updateStructure --verbose --execute Remove also php typo3/cli_dispatch.phpsh t3deploy database updateStructure --remove --verbose --execute
  • 55. THANK YOU! Krystian Szymukowicz k.szymukowicz@sourcebroker.net