SlideShare una empresa de Scribd logo
1 de 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)

Más contenido relacionado

Destacado

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
 

Destacado (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
 

Similar a 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
 

Similar a 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
 

Más 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
 

Más 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
 

Último

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 

Último (20)

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 

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)

Notas del editor

  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.