SlideShare a Scribd company logo
1 of 29
ExtBase Workshop
This is the plan...
• Hour 1: Create a basic shop extension
• Hour 2: Frontend & templating
• Hour 3: Writing code and add functionality
... and now the plan meets reality!
Part 1: Basics
Your working environment
• TYPO3 7.6
– use local installation if you have one
– use the jweiland starter package
• IDE: PHPStorm
• install Extensions: "extension_builder" and
"phpmyadmin"
• Code for this project:
https://github.com/aschmutt/t3extbase
Extension Builder
Extension Builder: Modelling
• New Model Object = table in database
• Domain Object Settings: aggregate root?
Yes means: Controller will be created
– use for central objects where controller makes sense
– do not use for subtables like: size, color,...
• Default Actions:
– if checked, code will be generated
– add more if you want - this can be done manually later
• Properties:
– fields like title, name, description
– generates: SQL for table fields, TCA for TYPO3 Backend, Object
properties with getter and setter
Extension Builder: Relations
• Add a field
– Type: database type of relation 1:1, 1:n, n:1, n:m
– Drag&Drop the dot to the other table (blue line)
Extension Builder Do's and Don't
• It looks like a UML modelling tool and/or code generator - but
it's not!!!
Its just some sample code, has versioning errors, etc.
Always read and understand the generated code!
• Good for:
– getting started
– first start of a extension, concept phase
– Code generation for tables, sql, Object model, TCA
• Bad for:
– difficult relations
– Anything that breaks the Object=Table pattern
– overwrite/merge options are available - but I don't trust them.
Make backups and use diff tools!
Our Project: NerdShop
• Create a small shop with items to make a nerd
happy!
• Product: our products we want to sell, like
shirts and gadgets
– Properties: title, description, image
• Order: a list of the items in our shopping cart
– Properties: orderNumber, name, address
– Relation: products n:m
Install Extension in TYPO3
• Extension Manager -> Install
– creates Database Tables
– every table change needs install again
• create a Page and add a Plugin Content Element
– choose your Frontend Plugin in Plugin Tab
– Page settings -> disable cache (for development)
• create a Data Folder and add some products
• Template configuration:
– add Extension Template on this page
– Info/Modify -> Edit the whole template record -> Include Static (from
extensions)
This adds our Configuration files: Configuration/TypoScript/setup.txt and
constants.txt
– add Data Folder UID to setup (31 is my example folder UID):
plugin.tx_nerdshop_shop.persistence.storagePid = 31
Practical Part
• Todo:
– Load your Plugin page in Frontend and see if page
shows "Listing..." of your plugin
– Add some products in Frontend and see if they are
in list view in backend
– edit products in backend, add images and see if
they appear in frontend
MVC
• Controller: Program Flow, Actions
• View: Templates & Fluid
• Model: Code, Repository, Database
Basic Setup ExtBase/Fluid
Model
Controller
Fluid Template
public function getTitle() {
return $this->title;
}
public function listAction() {
$products = $this->productRepository-
>findAll();
$this->view->assign('products', $products);
}
<f:for each="{products}" as="product">
<tr>
<td>
<f:link.action action="show"
arguments="{product : product}">
{product.title}
</f:link.action>
</td>
</tr>
</f:for>
Folder Structure
• Main Files:
– ext_emconf*: Extension
Manager config
– ext_icon*: Extension icon
– ext_localconf: Frontend config
– ext_tables.php: Backend config
– ext_tables.sql: SQL Statements
* required fields for a extension
Folder Structure
• Model
– /Classes Folder (without
Controller)
• View
– /Resources/Private:
Templates, Partials, Layouts
• Controller
– Classes/Controller
Folder Structure
• Configuration
– TCA: Backend Tables
– TypoScript
• Documentation
• Resources
– Language: Resources/Language
– Assets: Resources/Public
• Tests
– PHPUnit Tests
Practical part
• Download your generated code and open it in
PHPStorm (/typo3conf/ext/nerdshop)
• Read generated Code, identify Controller -
View - Model
• Click around in Frontend, URL shows name of
Controller and Action, and find where it is in
the code
Part 2: Frontend
Templates
• Idea: separate Code from HTML, use extra template
files
• Fluid is a template language to handle content (like
Smarty or Twig)
• Controller:
$title = $product->getTitle();
$this->view->assign('title',$title);
• View:
<h1>{title}</h1>
• https://docs.typo3.org/typo3cms/ExtbaseGuide/Flui
d/ViewHelper
Templates
• There is a Template hierarchy for a better structure:
• Layout:
– at least one empty file "Default.html"
– general layout, for example a extension wrapper
<div class="myextension>...</div>
• Templates
– one template for every action
– other templates are possible, e.g. Mail templates
• Partials
– reusable subparts
– example: Extension Builder generates "Properties.html" for show
action
Practical Part
• edit this Template files:
Resources/Private/Templates/Product/List.ht
ml
• edit some HTML and see result in Frontend
Let's add some Fluid
• show preview image:
<f:image
src="{product.image.originalResource.publi
cUrl}" width="100"/>
• parse HTML from RTE:
<f:format.html>{product.description}
</f:format.html>
• use Bootstrap buttons for some links:
<f:link.action class="btn btn-default"
action="edit" arguments="{product :
product}">Edit</f:link.action>
Add TypoScript, Css, Jss
• Create a nerdshop.js and nerdshop.css in
Resources folder
• Configuration/TypoScript/setup.txt:
page {
includeCSS {
nerdshop = EXT:nerdshop/Resources/Public/Css/nerdshop.css
}
includeJS {
nerdshop = EXT:nerdshop/Resources/Public/Js/nerdshop.js
}
}
• Template: Include Static (we did this in install
step already...)
Part 3: CRUD
Create - Read - Update - Delete
Database: Repository
• Lots of default functions:
– findAll = SELECT * FROM table
– findByName($val) =
SELECT * FROM table where name like „$val
– findOneByArticleNo($id)
SELECT … limit 1
– Add, remove, update, replace
• Query Syntax (same principle as doctrine):
$query->createQuery;
$query->matching(),
constraints,
$query->execute
• SQL Statements for raw queries:
$query->statement('SELECT ... HAVING ...')
• https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/3-implement-
individual-database-queries.html
Controller: new Action
• new Action: addToCart Button
• ProductController: add new function
public function addToCartAction(Product $product)
{ }
• ext_localconf.php: add Action-Name (function name without the string
"Action")
• HTML Template: add new file in View folder, 1. letter uppercase!
Resource/Private/Templates/Product/AddToCart.html
PHPDoc
• PHP Doc comments were made for code documentation, helper function popups,
class documentation:
@param int $number number for size
@return string
• You can generate automated documentation from phpdoc
• ExtBase uses PHPDoc Comments also for operations - so they are required now!
@validate
@inject
• Attention: PHP Opcode like
"eAccelerator" needs to be
configured, in default setting
the comments are removed!
Namespaces
• without namespaces, unique class names were like this:
class Tx_MyExtensionName_Controller_ContactController
extends Tx_Extbase_MVC_Controller_ActionController {...}
• with Namespace, it is like this:
namespace VendorMyExtensionNameController;
class ContactController extends
TYPO3CMSExtbaseMvcControllerActionController {...}
• shortcut for long namespaces:
use TYPO3CMSCoreUtilityGeneralUtility;
GeneralUtility::underscoredToUpperCamelCase($var);
• Learn more about Namespaces
– in PHP: http://php.net/manual/en/language.namespaces.php
– in TYPO3: https://docs.typo3.org/typo3cms/CoreApiReference/latest/
ApiOverview/Namespaces/
Where do I find documentation?
• Extension Builder: the kickstarter for Extbase
• Books and links:
– Developing TYPO3 Extensions with Extbase and Fluid, Sebastian
Kurfürst
Buch: O'Reilly Press
Online: https://docs.typo3.org/typo3cms/ExtbaseFluidBook/
– TYPO3 ExtBase, Patric Lobacher
Buch: Amazon Print OnDemand
eBook: https://leanpub.com/typo3extbase
– TYPO3 docs https://docs.typo3.org
• Extension Code
– News, Blog example extension
– sysext of Extbase and Fluid

More Related Content

What's hot

Big Data: Big SQL and HBase
Big Data:  Big SQL and HBase Big Data:  Big SQL and HBase
Big Data: Big SQL and HBase Cynthia Saracco
 
Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)April Sides
 
Gestione della configurazione in Drupal 8
Gestione della configurazione in Drupal 8Gestione della configurazione in Drupal 8
Gestione della configurazione in Drupal 8Eugenio Minardi
 
Hadoop, Hbase and Hive- Bay area Hadoop User Group
Hadoop, Hbase and Hive- Bay area Hadoop User GroupHadoop, Hbase and Hive- Bay area Hadoop User Group
Hadoop, Hbase and Hive- Bay area Hadoop User GroupHadoop User Group
 
Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Adding Value to HBase with IBM InfoSphere BigInsights and BigSQLAdding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Adding Value to HBase with IBM InfoSphere BigInsights and BigSQLPiotr Pruski
 
Hands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Hands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQLHands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Hands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQLPiotr Pruski
 
Cloudera Impala Internals
Cloudera Impala InternalsCloudera Impala Internals
Cloudera Impala InternalsDavid Groozman
 
Real-time Big Data Analytics Engine using Impala
Real-time Big Data Analytics Engine using ImpalaReal-time Big Data Analytics Engine using Impala
Real-time Big Data Analytics Engine using ImpalaJason Shih
 
9780538745840 ppt ch09
9780538745840 ppt ch099780538745840 ppt ch09
9780538745840 ppt ch09Terry Yoast
 
Drupal 8 deploying
Drupal 8 deployingDrupal 8 deploying
Drupal 8 deployingAndrew Siz
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowPantheon
 
9780538745840 ppt ch10
9780538745840 ppt ch109780538745840 ppt ch10
9780538745840 ppt ch10Terry Yoast
 
How Impala Works
How Impala WorksHow Impala Works
How Impala WorksYue Chen
 
Hive Quick Start Tutorial
Hive Quick Start TutorialHive Quick Start Tutorial
Hive Quick Start TutorialCarl Steinbach
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Zohar Elkayam
 
Friction-free ETL: Automating data transformation with Impala | Strata + Hado...
Friction-free ETL: Automating data transformation with Impala | Strata + Hado...Friction-free ETL: Automating data transformation with Impala | Strata + Hado...
Friction-free ETL: Automating data transformation with Impala | Strata + Hado...Cloudera, Inc.
 
Cloudera Impala technical deep dive
Cloudera Impala technical deep diveCloudera Impala technical deep dive
Cloudera Impala technical deep divehuguk
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmapHerman Duarte
 

What's hot (20)

Big Data: Big SQL and HBase
Big Data:  Big SQL and HBase Big Data:  Big SQL and HBase
Big Data: Big SQL and HBase
 
Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)Introduction to Module Development (Drupal 7)
Introduction to Module Development (Drupal 7)
 
Gestione della configurazione in Drupal 8
Gestione della configurazione in Drupal 8Gestione della configurazione in Drupal 8
Gestione della configurazione in Drupal 8
 
Hadoop, Hbase and Hive- Bay area Hadoop User Group
Hadoop, Hbase and Hive- Bay area Hadoop User GroupHadoop, Hbase and Hive- Bay area Hadoop User Group
Hadoop, Hbase and Hive- Bay area Hadoop User Group
 
Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Adding Value to HBase with IBM InfoSphere BigInsights and BigSQLAdding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
 
Hands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Hands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQLHands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
Hands-on-Lab: Adding Value to HBase with IBM InfoSphere BigInsights and BigSQL
 
Cloudera Impala Internals
Cloudera Impala InternalsCloudera Impala Internals
Cloudera Impala Internals
 
Real-time Big Data Analytics Engine using Impala
Real-time Big Data Analytics Engine using ImpalaReal-time Big Data Analytics Engine using Impala
Real-time Big Data Analytics Engine using Impala
 
9780538745840 ppt ch09
9780538745840 ppt ch099780538745840 ppt ch09
9780538745840 ppt ch09
 
Drupal 8 deploying
Drupal 8 deployingDrupal 8 deploying
Drupal 8 deploying
 
Test
TestTest
Test
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed Workflow
 
9780538745840 ppt ch10
9780538745840 ppt ch109780538745840 ppt ch10
9780538745840 ppt ch10
 
How Impala Works
How Impala WorksHow Impala Works
How Impala Works
 
Hive Quick Start Tutorial
Hive Quick Start TutorialHive Quick Start Tutorial
Hive Quick Start Tutorial
 
Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?Is SQLcl the Next Generation of SQL*Plus?
Is SQLcl the Next Generation of SQL*Plus?
 
Friction-free ETL: Automating data transformation with Impala | Strata + Hado...
Friction-free ETL: Automating data transformation with Impala | Strata + Hado...Friction-free ETL: Automating data transformation with Impala | Strata + Hado...
Friction-free ETL: Automating data transformation with Impala | Strata + Hado...
 
Drupal Modules
Drupal ModulesDrupal Modules
Drupal Modules
 
Cloudera Impala technical deep dive
Cloudera Impala technical deep diveCloudera Impala technical deep dive
Cloudera Impala technical deep dive
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmap
 

Similar to ExtBase workshop

Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyLeslie Doherty
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Dutyreedmaniac
 
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)Roman Zenner
 
ITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell ToolmakingITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell ToolmakingKurt Roggen [BE]
 
Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5Don Cranford
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the BasicsUlrich Krause
 
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Mark Hamstra
 
Suite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp OutputSuite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp OutputSuite Solutions
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and DesktopElizabeth Smith
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Drupalcon Paris
 
Get happy Editors with a suitable TYPO3 Backend Configuration
Get happy Editors with a suitable TYPO3 Backend ConfigurationGet happy Editors with a suitable TYPO3 Backend Configuration
Get happy Editors with a suitable TYPO3 Backend ConfigurationPeter Kraume
 
What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015
What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015
What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015die.agilen GmbH
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015Oro Inc.
 

Similar to ExtBase workshop (20)

presentation
presentationpresentation
presentation
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
Add-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his DutyAdd-On Development: EE Expects that Every Developer will do his Duty
Add-On Development: EE Expects that Every Developer will do his Duty
 
presentation
presentationpresentation
presentation
 
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
Modul-Entwicklung für Magento, OXID eShop und Shopware (2013)
 
ITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell ToolmakingITPROceed 2016 - The Art of PowerShell Toolmaking
ITPROceed 2016 - The Art of PowerShell Toolmaking
 
Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5Creating Custom Templates for Joomla! 2.5
Creating Custom Templates for Joomla! 2.5
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
Unleashing Creative Freedom with MODX (2015-09-03 at GroningenPHP)
 
Suite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp OutputSuite Labs: Generating SuiteHelp Output
Suite Labs: Generating SuiteHelp Output
 
Scaling / optimizing search on netlog
Scaling / optimizing search on netlogScaling / optimizing search on netlog
Scaling / optimizing search on netlog
 
Php on the Web and Desktop
Php on the Web and DesktopPhp on the Web and Desktop
Php on the Web and Desktop
 
Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3Staging Drupal 8 31 09 1 3
Staging Drupal 8 31 09 1 3
 
Web works hol
Web works holWeb works hol
Web works hol
 
Design to Theme @ CMSExpo
Design to Theme @ CMSExpoDesign to Theme @ CMSExpo
Design to Theme @ CMSExpo
 
Get happy Editors with a suitable TYPO3 Backend Configuration
Get happy Editors with a suitable TYPO3 Backend ConfigurationGet happy Editors with a suitable TYPO3 Backend Configuration
Get happy Editors with a suitable TYPO3 Backend Configuration
 
Ember - introduction
Ember - introductionEmber - introduction
Ember - introduction
 
What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015
What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015
What's new in TYPO3 6.2 LTS - #certiFUNcation Alumni Event 05.06.2015
 
OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015OroCRM Partner Technical Training: September 2015
OroCRM Partner Technical Training: September 2015
 
CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
 

Recently uploaded

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 

Recently uploaded (20)

Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 

ExtBase workshop

  • 2. This is the plan... • Hour 1: Create a basic shop extension • Hour 2: Frontend & templating • Hour 3: Writing code and add functionality ... and now the plan meets reality!
  • 4. Your working environment • TYPO3 7.6 – use local installation if you have one – use the jweiland starter package • IDE: PHPStorm • install Extensions: "extension_builder" and "phpmyadmin" • Code for this project: https://github.com/aschmutt/t3extbase
  • 6. Extension Builder: Modelling • New Model Object = table in database • Domain Object Settings: aggregate root? Yes means: Controller will be created – use for central objects where controller makes sense – do not use for subtables like: size, color,... • Default Actions: – if checked, code will be generated – add more if you want - this can be done manually later • Properties: – fields like title, name, description – generates: SQL for table fields, TCA for TYPO3 Backend, Object properties with getter and setter
  • 7. Extension Builder: Relations • Add a field – Type: database type of relation 1:1, 1:n, n:1, n:m – Drag&Drop the dot to the other table (blue line)
  • 8. Extension Builder Do's and Don't • It looks like a UML modelling tool and/or code generator - but it's not!!! Its just some sample code, has versioning errors, etc. Always read and understand the generated code! • Good for: – getting started – first start of a extension, concept phase – Code generation for tables, sql, Object model, TCA • Bad for: – difficult relations – Anything that breaks the Object=Table pattern – overwrite/merge options are available - but I don't trust them. Make backups and use diff tools!
  • 9. Our Project: NerdShop • Create a small shop with items to make a nerd happy! • Product: our products we want to sell, like shirts and gadgets – Properties: title, description, image • Order: a list of the items in our shopping cart – Properties: orderNumber, name, address – Relation: products n:m
  • 10. Install Extension in TYPO3 • Extension Manager -> Install – creates Database Tables – every table change needs install again • create a Page and add a Plugin Content Element – choose your Frontend Plugin in Plugin Tab – Page settings -> disable cache (for development) • create a Data Folder and add some products • Template configuration: – add Extension Template on this page – Info/Modify -> Edit the whole template record -> Include Static (from extensions) This adds our Configuration files: Configuration/TypoScript/setup.txt and constants.txt – add Data Folder UID to setup (31 is my example folder UID): plugin.tx_nerdshop_shop.persistence.storagePid = 31
  • 11. Practical Part • Todo: – Load your Plugin page in Frontend and see if page shows "Listing..." of your plugin – Add some products in Frontend and see if they are in list view in backend – edit products in backend, add images and see if they appear in frontend
  • 12. MVC • Controller: Program Flow, Actions • View: Templates & Fluid • Model: Code, Repository, Database
  • 13. Basic Setup ExtBase/Fluid Model Controller Fluid Template public function getTitle() { return $this->title; } public function listAction() { $products = $this->productRepository- >findAll(); $this->view->assign('products', $products); } <f:for each="{products}" as="product"> <tr> <td> <f:link.action action="show" arguments="{product : product}"> {product.title} </f:link.action> </td> </tr> </f:for>
  • 14. Folder Structure • Main Files: – ext_emconf*: Extension Manager config – ext_icon*: Extension icon – ext_localconf: Frontend config – ext_tables.php: Backend config – ext_tables.sql: SQL Statements * required fields for a extension
  • 15. Folder Structure • Model – /Classes Folder (without Controller) • View – /Resources/Private: Templates, Partials, Layouts • Controller – Classes/Controller
  • 16. Folder Structure • Configuration – TCA: Backend Tables – TypoScript • Documentation • Resources – Language: Resources/Language – Assets: Resources/Public • Tests – PHPUnit Tests
  • 17. Practical part • Download your generated code and open it in PHPStorm (/typo3conf/ext/nerdshop) • Read generated Code, identify Controller - View - Model • Click around in Frontend, URL shows name of Controller and Action, and find where it is in the code
  • 19. Templates • Idea: separate Code from HTML, use extra template files • Fluid is a template language to handle content (like Smarty or Twig) • Controller: $title = $product->getTitle(); $this->view->assign('title',$title); • View: <h1>{title}</h1> • https://docs.typo3.org/typo3cms/ExtbaseGuide/Flui d/ViewHelper
  • 20. Templates • There is a Template hierarchy for a better structure: • Layout: – at least one empty file "Default.html" – general layout, for example a extension wrapper <div class="myextension>...</div> • Templates – one template for every action – other templates are possible, e.g. Mail templates • Partials – reusable subparts – example: Extension Builder generates "Properties.html" for show action
  • 21. Practical Part • edit this Template files: Resources/Private/Templates/Product/List.ht ml • edit some HTML and see result in Frontend
  • 22. Let's add some Fluid • show preview image: <f:image src="{product.image.originalResource.publi cUrl}" width="100"/> • parse HTML from RTE: <f:format.html>{product.description} </f:format.html> • use Bootstrap buttons for some links: <f:link.action class="btn btn-default" action="edit" arguments="{product : product}">Edit</f:link.action>
  • 23. Add TypoScript, Css, Jss • Create a nerdshop.js and nerdshop.css in Resources folder • Configuration/TypoScript/setup.txt: page { includeCSS { nerdshop = EXT:nerdshop/Resources/Public/Css/nerdshop.css } includeJS { nerdshop = EXT:nerdshop/Resources/Public/Js/nerdshop.js } } • Template: Include Static (we did this in install step already...)
  • 24. Part 3: CRUD Create - Read - Update - Delete
  • 25. Database: Repository • Lots of default functions: – findAll = SELECT * FROM table – findByName($val) = SELECT * FROM table where name like „$val – findOneByArticleNo($id) SELECT … limit 1 – Add, remove, update, replace • Query Syntax (same principle as doctrine): $query->createQuery; $query->matching(), constraints, $query->execute • SQL Statements for raw queries: $query->statement('SELECT ... HAVING ...') • https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/3-implement- individual-database-queries.html
  • 26. Controller: new Action • new Action: addToCart Button • ProductController: add new function public function addToCartAction(Product $product) { } • ext_localconf.php: add Action-Name (function name without the string "Action") • HTML Template: add new file in View folder, 1. letter uppercase! Resource/Private/Templates/Product/AddToCart.html
  • 27. PHPDoc • PHP Doc comments were made for code documentation, helper function popups, class documentation: @param int $number number for size @return string • You can generate automated documentation from phpdoc • ExtBase uses PHPDoc Comments also for operations - so they are required now! @validate @inject • Attention: PHP Opcode like "eAccelerator" needs to be configured, in default setting the comments are removed!
  • 28. Namespaces • without namespaces, unique class names were like this: class Tx_MyExtensionName_Controller_ContactController extends Tx_Extbase_MVC_Controller_ActionController {...} • with Namespace, it is like this: namespace VendorMyExtensionNameController; class ContactController extends TYPO3CMSExtbaseMvcControllerActionController {...} • shortcut for long namespaces: use TYPO3CMSCoreUtilityGeneralUtility; GeneralUtility::underscoredToUpperCamelCase($var); • Learn more about Namespaces – in PHP: http://php.net/manual/en/language.namespaces.php – in TYPO3: https://docs.typo3.org/typo3cms/CoreApiReference/latest/ ApiOverview/Namespaces/
  • 29. Where do I find documentation? • Extension Builder: the kickstarter for Extbase • Books and links: – Developing TYPO3 Extensions with Extbase and Fluid, Sebastian Kurfürst Buch: O'Reilly Press Online: https://docs.typo3.org/typo3cms/ExtbaseFluidBook/ – TYPO3 ExtBase, Patric Lobacher Buch: Amazon Print OnDemand eBook: https://leanpub.com/typo3extbase – TYPO3 docs https://docs.typo3.org • Extension Code – News, Blog example extension – sysext of Extbase and Fluid