SlideShare une entreprise Scribd logo
1  sur  20
Making Your PHP Application Easy to Customize John Mertic @2010 SugarCRM Inc. All rights reserved.
Who Am I? John Mertic http://jmertic.wordpress.com Twitter: @jmertic jmertic@sugarcrm.com ( Work ) jmertic@php.net ( PHP ) Community Manager for SugarCRM http://www.sugarcrm.com Read our blog at http://developers.sugarcrm.com/wordpress 3/24/2011 @2011 SugarCRM Inc. All rights reserved. 2
My books 3/24/2011 @2011 SugarCRM Inc. All rights reserved. 3 http://amzn.to/enioPV http://t.co/UFRHNSO
7/22/2010 @2010 SugarCRM Inc. All rights reserved. Why should my app be easy to customize? 4 Source http://www.flickr.com/photos/duncan/4782911809
So how should you do this?
7/22/2010 @2010 SugarCRM Inc. All rights reserved. 6 Make your code open Source http://www.flickr.com/photos/igalko/4502271194
7/22/2010 @2010 SugarCRM Inc. All rights reserved. 7 Starting off with a good file structure
Things good to do here File naming convention Zend Framework approach Class Zend_Db_Table is at "Zend/Db/Table.php” Abstract class Zend_Controller_Request_Abstract is at “Zend/Controller/Request/Abstract.php” Interface Zend_Validate_Interface is at “Zend/Validate/Interface.php” Allowing file/class overrides SugarCRM approach Can drop in a replacement file in the same location in the custom/ directory Example: Override Contact’s detail view by dropping in a view.detail.php file in the custom/modules/Contacts/views/ directory. 7/27/11 @2010 SugarCRM Inc. All rights reserved. 8
7/22/2010 @2010 SugarCRM Inc. All rights reserved. 9 Source http://www.flickr.com/photos/cype_applejuice/43750657 Code Design
Dependency Injection class Widgets {     protected $_dbConn;     public function __construct()     {         $this->_dbConn = DBFactory::getInstance();     } } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 10
Dependency Injection class Widgets {     protected $_dbConn;     public function __construct( DBInstance $dbConn )     {         $this->_dbConn = $dbConn;     } } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 11
Dependency Injection class Widgets {     protected $_dbConn;     public function __construct() { }     public function setDBConnection(  DBInstance$dbConn )     {         $this->_dbConn = $dbConn;     } } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 12
Interfaces and Abstracts interface LoggerTemplate {     /**      * Main method for handling logging a message to the logger      *      * @param string $level logging level for the message      * @param string $message      */     public function log(         $method,         $message         ); } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 13
Interfaces and Abstracts abstract class loc_xml extends source {  	public function __parse($file)  	{  		$contents = file_get_contents($file);  		return simplexml_load_string($contents);  	}  	public abstract function getItem( 	$args=array(),  	$module=null); 	public abstract function getList( 	$args=array(),  	$module=null); } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 14
Factory Loaders class ControllerFactory { 	/** 	 * Obtain an instance of the correct controller. 	 *  	 * @return an instance of SugarController 	 */ 	function getController($module) 	{ 		$class = ucfirst($module).'Controller'; 		$customClass = 'Custom' . $class; 		if(file_exists('custom/modules/'.$module.'/controller.php')){ 			$customClass = 'Custom' . $class;		 require_once('custom/modules/'.$module.'/controller.php'); 			if(class_exists($customClass)){ 				$controller = new $customClass(); 			}else if(class_exists($class)){ 				$controller = new $class(); } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 15
Factory Loaders 		}elseif(file_exists('modules/'.$module.'/controller.php')){		 require_once('modules/'.$module.'/controller.php'); 			if(class_exists($customClass)){ 				$controller = new $customClass(); 			}else if(class_exists($class)){ 				$controller = new $class(); 			} 		}else{ 			if(file_exists('custom/include/MVC/Controller/SugarController.php')){ require_once('custom/include/MVC/Controller/SugarController.php'); 			} 			if(class_exists('CustomSugarController')){ 				$controller = new CustomSugarController(); 			}else{ 			$controller = new SugarController(); 			} 		} $controller->setup($module); 		return $controller; 	} } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 16
7/22/2010 @2010 SugarCRM Inc. All rights reserved. 17 Document it! Source: http://www.flickr.com/photos/nicecupoftea/3218211407
Ways to do this Docblock comments Example code Short blog posts/articles Forums / Mailing List Wiki Architectural documentation Full blown developer guide 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 18
7/22/2010 @2010 SugarCRM Inc. All rights reserved. 19 Source: http://www.flickr.com/photos/code_martial/4145914957 Learn from your developers
7/22/2010 @2010 SugarCRM Inc. All rights reserved. 20 Questions? To contact me after my presentation, text 2OR to INTRO (46876)

Contenu connexe

En vedette

Ergonomie : performance et satisfaction de nos clients
Ergonomie : performance et satisfaction de nos clientsErgonomie : performance et satisfaction de nos clients
Ergonomie : performance et satisfaction de nos clientsLaurence Vagner
 
L'Ergonomie pour les Nuls
L'Ergonomie pour les NulsL'Ergonomie pour les Nuls
L'Ergonomie pour les NulsPALO IT
 
Introduction à l'ergonomie - Drupal Lyon
Introduction à l'ergonomie - Drupal LyonIntroduction à l'ergonomie - Drupal Lyon
Introduction à l'ergonomie - Drupal LyonOlivier Lorrain
 
Poste de travail en parodontie
Poste de travail en parodontiePoste de travail en parodontie
Poste de travail en parodontieMounir ZAGHEZ
 
Charte Ergonomique
Charte Ergonomique Charte Ergonomique
Charte Ergonomique Rached Krim
 
Adapter son poste de travail, pourquoi ?
Adapter son poste de travail, pourquoi ?Adapter son poste de travail, pourquoi ?
Adapter son poste de travail, pourquoi ?DanSchwei
 
Ergonomie avec Microsoft Hardware
Ergonomie avec Microsoft HardwareErgonomie avec Microsoft Hardware
Ergonomie avec Microsoft HardwareNicolas Vernet
 
Gestion de Ressources Humaines
Gestion de Ressources HumainesGestion de Ressources Humaines
Gestion de Ressources Humainessharescholar
 
Td 1 notion d'ergonomie
Td 1 notion d'ergonomieTd 1 notion d'ergonomie
Td 1 notion d'ergonomieMounir ZAGHEZ
 
Ergonomie en entreprise
Ergonomie en entrepriseErgonomie en entreprise
Ergonomie en entrepriseHR SCOPE
 

En vedette (13)

Ergonomie : performance et satisfaction de nos clients
Ergonomie : performance et satisfaction de nos clientsErgonomie : performance et satisfaction de nos clients
Ergonomie : performance et satisfaction de nos clients
 
L'Ergonomie pour les Nuls
L'Ergonomie pour les NulsL'Ergonomie pour les Nuls
L'Ergonomie pour les Nuls
 
Introduction à l'ergonomie - Drupal Lyon
Introduction à l'ergonomie - Drupal LyonIntroduction à l'ergonomie - Drupal Lyon
Introduction à l'ergonomie - Drupal Lyon
 
Poste de travail en parodontie
Poste de travail en parodontiePoste de travail en parodontie
Poste de travail en parodontie
 
Diapo ressources humaines
Diapo ressources humainesDiapo ressources humaines
Diapo ressources humaines
 
Charte Ergonomique
Charte Ergonomique Charte Ergonomique
Charte Ergonomique
 
Gestion des ressources humaines
Gestion des ressources humainesGestion des ressources humaines
Gestion des ressources humaines
 
Adapter son poste de travail, pourquoi ?
Adapter son poste de travail, pourquoi ?Adapter son poste de travail, pourquoi ?
Adapter son poste de travail, pourquoi ?
 
Ergonomie avec Microsoft Hardware
Ergonomie avec Microsoft HardwareErgonomie avec Microsoft Hardware
Ergonomie avec Microsoft Hardware
 
Gestion de Ressources Humaines
Gestion de Ressources HumainesGestion de Ressources Humaines
Gestion de Ressources Humaines
 
Td 1 notion d'ergonomie
Td 1 notion d'ergonomieTd 1 notion d'ergonomie
Td 1 notion d'ergonomie
 
Ergonomie en entreprise
Ergonomie en entrepriseErgonomie en entreprise
Ergonomie en entreprise
 
Ergonomie
Ergonomie Ergonomie
Ergonomie
 

Similaire à OSCON 2011 - Making Your PHP Application Easy to Customize

20 ways the i pad can be a powerful
20 ways the i pad can be a powerful20 ways the i pad can be a powerful
20 ways the i pad can be a powerfulGMPDC
 
20 ways the_i_pad_can_be_a_powerful97
20 ways the_i_pad_can_be_a_powerful9720 ways the_i_pad_can_be_a_powerful97
20 ways the_i_pad_can_be_a_powerful97GMPDC
 
Using protobuf in your android app
Using protobuf in your android appUsing protobuf in your android app
Using protobuf in your android appMohsen Mirhoseini
 
Cocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.twCocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.twYu-Wei Chuang
 
Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )John Mertic
 
ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-
ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-
ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-Jun-ichi Sakamoto
 
OSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM PlatformOSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM PlatformJohn Mertic
 
Job Managment Portlet
Job Managment PortletJob Managment Portlet
Job Managment Portletriround
 
SharePoint Migration What do I expect ? (The issues and solutions)
SharePoint Migration What do I expect ? (The issues and solutions)SharePoint Migration What do I expect ? (The issues and solutions)
SharePoint Migration What do I expect ? (The issues and solutions)K.Mohamed Faizal
 
Facebook Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend FrameworkBrett Harris
 
Movable Type 5 Smartphone Option
Movable Type 5 Smartphone OptionMovable Type 5 Smartphone Option
Movable Type 5 Smartphone OptionSix Apart KK
 
managing your content
managing your contentmanaging your content
managing your contentSamsung
 
Oracle Application Framework Cases
Oracle Application Framework Cases Oracle Application Framework Cases
Oracle Application Framework Cases Feras Ahmad
 
How To Write A Robot For Google Wave
How To Write A Robot For Google WaveHow To Write A Robot For Google Wave
How To Write A Robot For Google WaveMaximumHit Ltd
 
Facebook's Apps II part
Facebook's Apps II partFacebook's Apps II part
Facebook's Apps II partFelix Rivas
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your appSamsung
 
Google Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocialGoogle Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocialPatrick Chanezon
 
IMS Learning Tools Interoperability @ UCLA
IMS Learning Tools Interoperability @ UCLAIMS Learning Tools Interoperability @ UCLA
IMS Learning Tools Interoperability @ UCLACharles Severance
 
Movable Type Seminar 2011
Movable Type Seminar 2011Movable Type Seminar 2011
Movable Type Seminar 2011Six Apart KK
 

Similaire à OSCON 2011 - Making Your PHP Application Easy to Customize (20)

20 ways the i pad can be a powerful
20 ways the i pad can be a powerful20 ways the i pad can be a powerful
20 ways the i pad can be a powerful
 
20 ways the_i_pad_can_be_a_powerful97
20 ways the_i_pad_can_be_a_powerful9720 ways the_i_pad_can_be_a_powerful97
20 ways the_i_pad_can_be_a_powerful97
 
Using protobuf in your android app
Using protobuf in your android appUsing protobuf in your android app
Using protobuf in your android app
 
Cocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.twCocktails – Shaken, Not Stirred @osdc.tw
Cocktails – Shaken, Not Stirred @osdc.tw
 
Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )Developing Easily Deployable PHP Applications ( OSCON 2010 )
Developing Easily Deployable PHP Applications ( OSCON 2010 )
 
ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-
ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-
ASP.NET で作るとあるTwitter Bot -開発環境からネット公開までぜんぶ無料だよ!-
 
OSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM PlatformOSCON 2011 - Building An Application On The SugarCRM Platform
OSCON 2011 - Building An Application On The SugarCRM Platform
 
Job Managment Portlet
Job Managment PortletJob Managment Portlet
Job Managment Portlet
 
Django introduction
Django introductionDjango introduction
Django introduction
 
SharePoint Migration What do I expect ? (The issues and solutions)
SharePoint Migration What do I expect ? (The issues and solutions)SharePoint Migration What do I expect ? (The issues and solutions)
SharePoint Migration What do I expect ? (The issues and solutions)
 
Facebook Development with Zend Framework
Facebook Development with Zend FrameworkFacebook Development with Zend Framework
Facebook Development with Zend Framework
 
Movable Type 5 Smartphone Option
Movable Type 5 Smartphone OptionMovable Type 5 Smartphone Option
Movable Type 5 Smartphone Option
 
managing your content
managing your contentmanaging your content
managing your content
 
Oracle Application Framework Cases
Oracle Application Framework Cases Oracle Application Framework Cases
Oracle Application Framework Cases
 
How To Write A Robot For Google Wave
How To Write A Robot For Google WaveHow To Write A Robot For Google Wave
How To Write A Robot For Google Wave
 
Facebook's Apps II part
Facebook's Apps II partFacebook's Apps II part
Facebook's Apps II part
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your app
 
Google Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocialGoogle Devfest Singapore - OpenSocial
Google Devfest Singapore - OpenSocial
 
IMS Learning Tools Interoperability @ UCLA
IMS Learning Tools Interoperability @ UCLAIMS Learning Tools Interoperability @ UCLA
IMS Learning Tools Interoperability @ UCLA
 
Movable Type Seminar 2011
Movable Type Seminar 2011Movable Type Seminar 2011
Movable Type Seminar 2011
 

Plus de John Mertic

The Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar StoryThe Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar StoryJohn Mertic
 
PHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cubePHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cubeJohn Mertic
 
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...John Mertic
 
Astricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBXAstricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBXJohn Mertic
 
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...John Mertic
 
Making Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceMaking Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceJohn Mertic
 
SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5John Mertic
 
SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework John Mertic
 
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in SugarSugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in SugarJohn Mertic
 
2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRM2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRMJohn Mertic
 

Plus de John Mertic (10)

The Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar StoryThe Virtual Git Summit - Subversion to Git - A Sugar Story
The Virtual Git Summit - Subversion to Git - A Sugar Story
 
PHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cubePHPBenelux 2012 - Working successfully outside the cube
PHPBenelux 2012 - Working successfully outside the cube
 
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
LinuxCon Brazil 2011 - Hack your team, your Department, and Your Organization...
 
Astricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBXAstricon 2011 - Connecting SugarCRM with your PBX
Astricon 2011 - Connecting SugarCRM with your PBX
 
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
LinuxTag 2011 - Using SugarCRM when you aren't doing CRM Examples of SugarCRM...
 
Making Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceMaking Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux Conference
 
SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5SugarCON 2009 - Theme Development in Sugar 5.5
SugarCON 2009 - Theme Development in Sugar 5.5
 
SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework SugarCon 2010 - Sugar as a Business Application Framework
SugarCon 2010 - Sugar as a Business Application Framework
 
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in SugarSugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
SugarCon 2010 - Best Practices for Creating Custom Apps in Sugar
 
2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRM2009 Ontario GNU Linux Fest - Build your business on SugarCRM
2009 Ontario GNU Linux Fest - Build your business on SugarCRM
 

Dernier

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Dernier (20)

AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

OSCON 2011 - Making Your PHP Application Easy to Customize

  • 1. Making Your PHP Application Easy to Customize John Mertic @2010 SugarCRM Inc. All rights reserved.
  • 2. Who Am I? John Mertic http://jmertic.wordpress.com Twitter: @jmertic jmertic@sugarcrm.com ( Work ) jmertic@php.net ( PHP ) Community Manager for SugarCRM http://www.sugarcrm.com Read our blog at http://developers.sugarcrm.com/wordpress 3/24/2011 @2011 SugarCRM Inc. All rights reserved. 2
  • 3. My books 3/24/2011 @2011 SugarCRM Inc. All rights reserved. 3 http://amzn.to/enioPV http://t.co/UFRHNSO
  • 4. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. Why should my app be easy to customize? 4 Source http://www.flickr.com/photos/duncan/4782911809
  • 5. So how should you do this?
  • 6. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 6 Make your code open Source http://www.flickr.com/photos/igalko/4502271194
  • 7. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 7 Starting off with a good file structure
  • 8. Things good to do here File naming convention Zend Framework approach Class Zend_Db_Table is at "Zend/Db/Table.php” Abstract class Zend_Controller_Request_Abstract is at “Zend/Controller/Request/Abstract.php” Interface Zend_Validate_Interface is at “Zend/Validate/Interface.php” Allowing file/class overrides SugarCRM approach Can drop in a replacement file in the same location in the custom/ directory Example: Override Contact’s detail view by dropping in a view.detail.php file in the custom/modules/Contacts/views/ directory. 7/27/11 @2010 SugarCRM Inc. All rights reserved. 8
  • 9. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 9 Source http://www.flickr.com/photos/cype_applejuice/43750657 Code Design
  • 10. Dependency Injection class Widgets { protected $_dbConn; public function __construct() { $this->_dbConn = DBFactory::getInstance(); } } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 10
  • 11. Dependency Injection class Widgets { protected $_dbConn; public function __construct( DBInstance $dbConn ) { $this->_dbConn = $dbConn; } } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 11
  • 12. Dependency Injection class Widgets { protected $_dbConn; public function __construct() { } public function setDBConnection( DBInstance$dbConn ) { $this->_dbConn = $dbConn; } } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 12
  • 13. Interfaces and Abstracts interface LoggerTemplate { /** * Main method for handling logging a message to the logger * * @param string $level logging level for the message * @param string $message */ public function log( $method, $message ); } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 13
  • 14. Interfaces and Abstracts abstract class loc_xml extends source { public function __parse($file) { $contents = file_get_contents($file); return simplexml_load_string($contents); } public abstract function getItem( $args=array(), $module=null); public abstract function getList( $args=array(), $module=null); } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 14
  • 15. Factory Loaders class ControllerFactory { /** * Obtain an instance of the correct controller. * * @return an instance of SugarController */ function getController($module) { $class = ucfirst($module).'Controller'; $customClass = 'Custom' . $class; if(file_exists('custom/modules/'.$module.'/controller.php')){ $customClass = 'Custom' . $class; require_once('custom/modules/'.$module.'/controller.php'); if(class_exists($customClass)){ $controller = new $customClass(); }else if(class_exists($class)){ $controller = new $class(); } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 15
  • 16. Factory Loaders }elseif(file_exists('modules/'.$module.'/controller.php')){ require_once('modules/'.$module.'/controller.php'); if(class_exists($customClass)){ $controller = new $customClass(); }else if(class_exists($class)){ $controller = new $class(); } }else{ if(file_exists('custom/include/MVC/Controller/SugarController.php')){ require_once('custom/include/MVC/Controller/SugarController.php'); } if(class_exists('CustomSugarController')){ $controller = new CustomSugarController(); }else{ $controller = new SugarController(); } } $controller->setup($module); return $controller; } } 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 16
  • 17. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 17 Document it! Source: http://www.flickr.com/photos/nicecupoftea/3218211407
  • 18. Ways to do this Docblock comments Example code Short blog posts/articles Forums / Mailing List Wiki Architectural documentation Full blown developer guide 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 18
  • 19. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 19 Source: http://www.flickr.com/photos/code_martial/4145914957 Learn from your developers
  • 20. 7/22/2010 @2010 SugarCRM Inc. All rights reserved. 20 Questions? To contact me after my presentation, text 2OR to INTRO (46876)

Notes de l'éditeur

  1. So CRM is not about technology butall about Customers, YOUR Customers.
  2. User base is diverse, likes different offerings, and will move between them.Lots of choices ( Web Servers / OSes / Databases / PHP versions ) as well as config possibilitiesHave to cover lots of platforms; can rely on particular hardware or software being available.
  3. User base is diverse, likes different offerings, and will move between them.Lots of choices ( Web Servers / OSes / Databases / PHP versions ) as well as config possibilitiesHave to cover lots of platforms; can rely on particular hardware or software being available.
  4. User base is diverse, likes different offerings, and will move between them.Lots of choices ( Web Servers / OSes / Databases / PHP versions ) as well as config possibilitiesHave to cover lots of platforms; can rely on particular hardware or software being available.