SlideShare ist ein Scribd-Unternehmen logo
1 von 16
PHP for Enterprise

PSR Introduction
Võ Duy Tuấn
CEO/Founder @ spiral.vn

 PHP 5 Zend Certified Engineer
 Mobile App Developer

 Web Developer & Designer
 Interest:
o PHP
o Large System & Data Mining
o Web Performance Optimization
o Mobile Development
AGENDA
Why Standard?
How case-sensitive server kills PSR-0?
Question & Answer
1. Why Standard?
PSR FAMILY (http://www.php-fig.org/)
•
•
•
•
•

PSR-0
PSR-1
PSR-2
PSR-3
PSR-4
PSR-0 : Autoloading
•

•
•
•
•
•
•

A fully-qualified namespace and class must have the following structure
<Vendor Name>(<Namespace>)*<Class Name>
Each namespace must have a top-level namespace ("Vendor Name").
Each namespace can have as many sub-namespaces as it wishes.
Each namespace separator is converted to a DIRECTORY_SEPARATOR when
loading from the file system.
Each _ character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR.
The _ character has no special meaning in the namespace.
The fully-qualified namespace and class is suffixed with .php when loading
from the file system.
Alphabetic characters in vendor names, namespaces, and class names may be
of any combination of lower case and upper case.
PSR-1 : Basic Coding Standard
• Files MUST use only <?php and <?= tags.

• Files MUST use only UTF-8 without BOM for PHP code.
• Files SHOULD either declare symbols (classes, functions,
constants, etc.) or cause side-effects (e.g. generate output,
change .ini settings, etc.) but SHOULD NOT do both.

• Namespaces and classes MUST follow PSR-0.
• Class names MUST be declared in StudlyCaps.
• Class constants MUST be declared in all upper case with
underscore separators.
• Method names MUST be declared in camelCase.
PSR-2 : Coding Style Guide
•
•
•
•
•

•
•
•
•
•

Code MUST follow PSR-1.
Code MUST use 4 spaces for indenting, not tabs.
There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines
SHOULD be 80 characters or less.
There MUST be one blank line after the namespace declaration, and there MUST be one
blank line after the block of use declarations.
Opening braces for classes MUST go on the next line, and closing braces MUST go on the next
line after the body.
Opening braces for methods MUST go on the next line, and closing braces MUST go on the
next line after the body.
Visibility MUST be declared on all properties and methods; abstract and final MUST be
declared before the visibility; static MUST be declared after the visibility.
Control structure keywords MUST have one space after them; method and function calls
MUST NOT.
Opening braces for control structures MUST go on the same line, and closing braces MUST go
on the next line after the body.
Opening parentheses for control structures MUST NOT have a space after them, and closing
parentheses for control structures MUST NOT have a space before.
2. How Case-sensitive
server kills PSR-0 ?
PSR-0 PROBLEM
• If user type: http://abc.com/admin/product
-> Most framework rewrite engine will parsing URL and return
information about included controller:
- Module: admin
- Controller: product
- Action: index (default)
PSR-0 PROBLEM (cont..)
• If follow PSR-0, your autoloader will include controller file somewhere like:

…/controller/admin/product.php
• And, your controller class must be something like :
<?php
namespace controlleradmin;
class product extends basecontroller
{
…
}
Where is Problem ?!
PSR-0 PROBLEM (cont..)
• If follow PSR-1, your Class name must be something like:
Product not product
• And, if your classname is Product, your controller file must be:
…/controller/admin/Product.php
• So that, for autoloader works, your URL must be:
http://abc.com/admin/Product
• So, you MUST change all URL structure of your website 
Solution…
CLASSMAP
• Hook before autoloader include controller file, something like
this:
…
'controlleradminproduct' => 'Controller/Admin/Product.php'

…
Thank you!
CONTACT ME:
tuanmaster2002@yahoo.com
0938 916 902
http://bloghoctap.com/

Weitere ähnliche Inhalte

Was ist angesagt?

Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
LumoSpark
 

Was ist angesagt? (20)

Composer
ComposerComposer
Composer
 
Web service with Laravel
Web service with LaravelWeb service with Laravel
Web service with Laravel
 
Phalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil ConferencePhalcon 2 - PHP Brazil Conference
Phalcon 2 - PHP Brazil Conference
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)Web development automatisation for fun and profit (Artem Daniliants)
Web development automatisation for fun and profit (Artem Daniliants)
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
 
PHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP ServerPHP-MySQL Database Connectivity Using XAMPP Server
PHP-MySQL Database Connectivity Using XAMPP Server
 
Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11Capifony. Minsk PHP MeetUp #11
Capifony. Minsk PHP MeetUp #11
 
Php Ppt
Php PptPhp Ppt
Php Ppt
 
Composer The Right Way - 010PHP
Composer The Right Way - 010PHPComposer The Right Way - 010PHP
Composer The Right Way - 010PHP
 
Manage appium dependencies with -appium-home in appium 2.0
Manage appium dependencies with  -appium-home in appium 2.0Manage appium dependencies with  -appium-home in appium 2.0
Manage appium dependencies with -appium-home in appium 2.0
 
MySQL Presentation
MySQL PresentationMySQL Presentation
MySQL Presentation
 
Laravel 5.3 - Web Development Php framework
Laravel 5.3 - Web Development Php frameworkLaravel 5.3 - Web Development Php framework
Laravel 5.3 - Web Development Php framework
 
Caching the Uncacheable
Caching the UncacheableCaching the Uncacheable
Caching the Uncacheable
 
Tomcat Server
Tomcat ServerTomcat Server
Tomcat Server
 
Testing Web Apps With Scripting Language - Mark Rees, Century Software
Testing Web Apps With Scripting Language - Mark Rees, Century SoftwareTesting Web Apps With Scripting Language - Mark Rees, Century Software
Testing Web Apps With Scripting Language - Mark Rees, Century Software
 
Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16Composer the Right Way - PHPBNL16
Composer the Right Way - PHPBNL16
 
Add new commands in appium 2.0
Add new commands in appium 2.0Add new commands in appium 2.0
Add new commands in appium 2.0
 
Apc presentation
Apc presentationApc presentation
Apc presentation
 
PHP: The Beginning and the Zend
PHP: The Beginning and the ZendPHP: The Beginning and the Zend
PHP: The Beginning and the Zend
 

Andere mochten auch

Javascript unit testing framework
Javascript unit testing frameworkJavascript unit testing framework
Javascript unit testing framework
Võ Duy Tuấn
 
Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22
Võ Duy Tuấn
 
Magento overview and how sell Magento extensions
Magento overview and how sell Magento extensionsMagento overview and how sell Magento extensions
Magento overview and how sell Magento extensions
Võ Duy Tuấn
 

Andere mochten auch (20)

React introduction
React introductionReact introduction
React introduction
 
Scale with Microservices
Scale with MicroservicesScale with Microservices
Scale with Microservices
 
Microservices and docker
Microservices and dockerMicroservices and docker
Microservices and docker
 
Chatbot in Sale Management
Chatbot in Sale ManagementChatbot in Sale Management
Chatbot in Sale Management
 
Business Intelligence in Retail Industry
Business Intelligence in Retail IndustryBusiness Intelligence in Retail Industry
Business Intelligence in Retail Industry
 
How to Build Recommender System with Content based Filtering
How to Build Recommender System with Content based FilteringHow to Build Recommender System with Content based Filtering
How to Build Recommender System with Content based Filtering
 
Microservices in production
Microservices in productionMicroservices in production
Microservices in production
 
Caching strategy and apc
Caching strategy and apcCaching strategy and apc
Caching strategy and apc
 
Heavy Web Optimization: Frontend
Heavy Web Optimization: FrontendHeavy Web Optimization: Frontend
Heavy Web Optimization: Frontend
 
laravel Elegant artisan by santosh pawar
laravel Elegant artisan by santosh pawarlaravel Elegant artisan by santosh pawar
laravel Elegant artisan by santosh pawar
 
Javascript unit testing framework
Javascript unit testing frameworkJavascript unit testing framework
Javascript unit testing framework
 
Keeping Eloquent Eloquent
Keeping Eloquent EloquentKeeping Eloquent Eloquent
Keeping Eloquent Eloquent
 
Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22Speed up with hiphop php 2014 01-22
Speed up with hiphop php 2014 01-22
 
Stop multiplying by 4 Laracon
Stop multiplying by 4 LaraconStop multiplying by 4 Laracon
Stop multiplying by 4 Laracon
 
Heavy Web Optimization: Backend
Heavy Web Optimization: BackendHeavy Web Optimization: Backend
Heavy Web Optimization: Backend
 
01- instalacion de laravel 5+ (dos formas sencillas )
01- instalacion de laravel 5+ (dos formas sencillas )01- instalacion de laravel 5+ (dos formas sencillas )
01- instalacion de laravel 5+ (dos formas sencillas )
 
Magento overview and how sell Magento extensions
Magento overview and how sell Magento extensionsMagento overview and how sell Magento extensions
Magento overview and how sell Magento extensions
 
Writing Test Cases with PHPUnit
Writing Test Cases with PHPUnitWriting Test Cases with PHPUnit
Writing Test Cases with PHPUnit
 
NodeJS Microservices, Built it Now, Scale it Later!
NodeJS Microservices, Built it Now, Scale it Later!NodeJS Microservices, Built it Now, Scale it Later!
NodeJS Microservices, Built it Now, Scale it Later!
 
Conociendo a Laravel, el Framework de PHP para artesanos de la web
Conociendo a Laravel, el Framework de PHP para artesanos de la webConociendo a Laravel, el Framework de PHP para artesanos de la web
Conociendo a Laravel, el Framework de PHP para artesanos de la web
 

Ähnlich wie Php psr standard 2014 01-22

Ähnlich wie Php psr standard 2014 01-22 (20)

An intro to php standards recommendation (psr)
An intro to php standards recommendation (psr)An intro to php standards recommendation (psr)
An intro to php standards recommendation (psr)
 
PHP 8: What's New and Changed
PHP 8: What's New and ChangedPHP 8: What's New and Changed
PHP 8: What's New and Changed
 
2021.laravelconf.tw.slides2
2021.laravelconf.tw.slides22021.laravelconf.tw.slides2
2021.laravelconf.tw.slides2
 
PHP Standards Recommendations - PHP-FIG
PHP Standards Recommendations - PHP-FIGPHP Standards Recommendations - PHP-FIG
PHP Standards Recommendations - PHP-FIG
 
Psr - php standards recommendations
Psr - php standards recommendationsPsr - php standards recommendations
Psr - php standards recommendations
 
Composer Helpdesk
Composer HelpdeskComposer Helpdesk
Composer Helpdesk
 
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
Workshop: Symfony2 Intruduction: (Controller, Routing, Model)
 
Namespaces and Autoloading
Namespaces and AutoloadingNamespaces and Autoloading
Namespaces and Autoloading
 
My Saminar On Php
My Saminar On PhpMy Saminar On Php
My Saminar On Php
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy serverBeyond 'Set it and Forget it': Proactively managing your EZproxy server
Beyond 'Set it and Forget it': Proactively managing your EZproxy server
 
PSR: Standards in PHP by Alex Simanovich
PSR: Standards in PHP by Alex SimanovichPSR: Standards in PHP by Alex Simanovich
PSR: Standards in PHP by Alex Simanovich
 
Hibernate java and_oracle
Hibernate java and_oracleHibernate java and_oracle
Hibernate java and_oracle
 
20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards20 PHP Static Analysis and Documentation Generators #burningkeyboards
20 PHP Static Analysis and Documentation Generators #burningkeyboards
 
The Art of Metaprogramming in Java
The Art of Metaprogramming in Java  The Art of Metaprogramming in Java
The Art of Metaprogramming in Java
 
The Query Rewrite Plugin Interface: Writing Your Own Plugin
The Query Rewrite Plugin Interface: Writing Your Own PluginThe Query Rewrite Plugin Interface: Writing Your Own Plugin
The Query Rewrite Plugin Interface: Writing Your Own Plugin
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
 
Custom post-framworks
Custom post-framworksCustom post-framworks
Custom post-framworks
 

Mehr von Võ Duy Tuấn

Html5, css3 and the future of web technologies
Html5, css3 and the future of web technologiesHtml5, css3 and the future of web technologies
Html5, css3 and the future of web technologies
Võ Duy Tuấn
 
How startups can benefit from launch community
How startups can benefit from launch communityHow startups can benefit from launch community
How startups can benefit from launch community
Võ Duy Tuấn
 
Zingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHPZingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHP
Võ Duy Tuấn
 
Xây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupalXây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupal
Võ Duy Tuấn
 
Speed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension moduleSpeed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension module
Võ Duy Tuấn
 
Hanoi php day 2010 program
Hanoi php day 2010   programHanoi php day 2010   program
Hanoi php day 2010 program
Võ Duy Tuấn
 
Social network game service
Social network game serviceSocial network game service
Social network game service
Võ Duy Tuấn
 

Mehr von Võ Duy Tuấn (15)

Log management system for Microservices
Log management system for MicroservicesLog management system for Microservices
Log management system for Microservices
 
Multi-tenant Database Design for SaaS
Multi-tenant Database Design for SaaSMulti-tenant Database Design for SaaS
Multi-tenant Database Design for SaaS
 
Flutter introduction
Flutter introductionFlutter introduction
Flutter introduction
 
Mobile outsourcing best practices
Mobile outsourcing best practicesMobile outsourcing best practices
Mobile outsourcing best practices
 
How to build a Recommender System
How to build a Recommender SystemHow to build a Recommender System
How to build a Recommender System
 
Mobile for web
Mobile for webMobile for web
Mobile for web
 
Reader.vn 2012 - The Book Of Life
Reader.vn 2012 - The Book Of LifeReader.vn 2012 - The Book Of Life
Reader.vn 2012 - The Book Of Life
 
Html5, css3 and the future of web technologies
Html5, css3 and the future of web technologiesHtml5, css3 and the future of web technologies
Html5, css3 and the future of web technologies
 
How startups can benefit from launch community
How startups can benefit from launch communityHow startups can benefit from launch community
How startups can benefit from launch community
 
Zingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHPZingme practice for building scalable website with PHP
Zingme practice for building scalable website with PHP
 
Xây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupalXây dựng mạng xã hội bằng drupal
Xây dựng mạng xã hội bằng drupal
 
Web optimization
Web optimizationWeb optimization
Web optimization
 
Speed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension moduleSpeed up zing me – ntvv2 code with PHP extension module
Speed up zing me – ntvv2 code with PHP extension module
 
Hanoi php day 2010 program
Hanoi php day 2010   programHanoi php day 2010   program
Hanoi php day 2010 program
 
Social network game service
Social network game serviceSocial network game service
Social network game service
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
vu2urc
 

Kürzlich hochgeladen (20)

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...
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
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
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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...
 
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
 

Php psr standard 2014 01-22

  • 1. PHP for Enterprise PSR Introduction
  • 2. Võ Duy Tuấn CEO/Founder @ spiral.vn  PHP 5 Zend Certified Engineer  Mobile App Developer  Web Developer & Designer  Interest: o PHP o Large System & Data Mining o Web Performance Optimization o Mobile Development
  • 3. AGENDA Why Standard? How case-sensitive server kills PSR-0? Question & Answer
  • 6. PSR-0 : Autoloading • • • • • • • A fully-qualified namespace and class must have the following structure <Vendor Name>(<Namespace>)*<Class Name> Each namespace must have a top-level namespace ("Vendor Name"). Each namespace can have as many sub-namespaces as it wishes. Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system. Each _ character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The _ character has no special meaning in the namespace. The fully-qualified namespace and class is suffixed with .php when loading from the file system. Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case.
  • 7. PSR-1 : Basic Coding Standard • Files MUST use only <?php and <?= tags. • Files MUST use only UTF-8 without BOM for PHP code. • Files SHOULD either declare symbols (classes, functions, constants, etc.) or cause side-effects (e.g. generate output, change .ini settings, etc.) but SHOULD NOT do both. • Namespaces and classes MUST follow PSR-0. • Class names MUST be declared in StudlyCaps. • Class constants MUST be declared in all upper case with underscore separators. • Method names MUST be declared in camelCase.
  • 8. PSR-2 : Coding Style Guide • • • • • • • • • • Code MUST follow PSR-1. Code MUST use 4 spaces for indenting, not tabs. There MUST NOT be a hard limit on line length; the soft limit MUST be 120 characters; lines SHOULD be 80 characters or less. There MUST be one blank line after the namespace declaration, and there MUST be one blank line after the block of use declarations. Opening braces for classes MUST go on the next line, and closing braces MUST go on the next line after the body. Opening braces for methods MUST go on the next line, and closing braces MUST go on the next line after the body. Visibility MUST be declared on all properties and methods; abstract and final MUST be declared before the visibility; static MUST be declared after the visibility. Control structure keywords MUST have one space after them; method and function calls MUST NOT. Opening braces for control structures MUST go on the same line, and closing braces MUST go on the next line after the body. Opening parentheses for control structures MUST NOT have a space after them, and closing parentheses for control structures MUST NOT have a space before.
  • 10. PSR-0 PROBLEM • If user type: http://abc.com/admin/product -> Most framework rewrite engine will parsing URL and return information about included controller: - Module: admin - Controller: product - Action: index (default)
  • 11. PSR-0 PROBLEM (cont..) • If follow PSR-0, your autoloader will include controller file somewhere like: …/controller/admin/product.php • And, your controller class must be something like : <?php namespace controlleradmin; class product extends basecontroller { … }
  • 13. PSR-0 PROBLEM (cont..) • If follow PSR-1, your Class name must be something like: Product not product • And, if your classname is Product, your controller file must be: …/controller/admin/Product.php • So that, for autoloader works, your URL must be: http://abc.com/admin/Product • So, you MUST change all URL structure of your website 
  • 15. CLASSMAP • Hook before autoloader include controller file, something like this: … 'controlleradminproduct' => 'Controller/Admin/Product.php' …