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

En vedette

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
 
Inventory Control Esso
Inventory Control EssoInventory Control Esso
Inventory Control EssoRamon Saviñon
 
Multicultural marketing 3rd Session
Multicultural marketing 3rd Session Multicultural marketing 3rd Session
Multicultural marketing 3rd Session ICD-Ecole
 

En vedette (20)

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
 
Inventory Control Esso
Inventory Control EssoInventory Control Esso
Inventory Control Esso
 
Instrumentasi
InstrumentasiInstrumentasi
Instrumentasi
 
Mrówka
MrówkaMrówka
Mrówka
 
Multicultural marketing 3rd Session
Multicultural marketing 3rd Session Multicultural marketing 3rd Session
Multicultural marketing 3rd Session
 

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

"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"growthgrids
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...nirzagarg
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdfMatthew Sinclair
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...SUHANI PANDEY
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...SUHANI PANDEY
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...SUHANI PANDEY
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查ydyuyu
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋nirzagarg
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445ruhi
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...kajalverma014
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge GraphsEleniIlkou
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdfMatthew Sinclair
 

Dernier (20)

"Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency""Boost Your Digital Presence: Partner with a Leading SEO Agency"
"Boost Your Digital Presence: Partner with a Leading SEO Agency"
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Himatnagar 7001035870 Whatsapp Number, 24/07 Booking
 
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men  🔝mehsana🔝   Escorts...
➥🔝 7737669865 🔝▻ mehsana Call-girls in Women Seeking Men 🔝mehsana🔝 Escorts...
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf20240508 QFM014 Elixir Reading List April 2024.pdf
20240508 QFM014 Elixir Reading List April 2024.pdf
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
Sarola * Female Escorts Service in Pune | 8005736733 Independent Escorts & Da...
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
Wagholi & High Class Call Girls Pune Neha 8005736733 | 100% Gennuine High Cla...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查在线制作约克大学毕业证(yu毕业证)在读证明认证可查
在线制作约克大学毕业证(yu毕业证)在读证明认证可查
 
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
📱Dehradun Call Girls Service 📱☎️ +91'905,3900,678 ☎️📱 Call Girls In Dehradun 📱
 
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
💚😋 Salem Escort Service Call Girls, 9352852248 ₹5000 To 25K With AC💚😋
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
All Time Service Available Call Girls Mg Road 👌 ⏭️ 6378878445
 
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
best call girls in Hyderabad Finest Escorts Service 📞 9352988975 📞 Available ...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
20240507 QFM013 Machine Intelligence Reading List April 2024.pdf
 

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