<?php
$db = connect_mysql('192.168.1.1', 'root' , 'secretPassword123' );
$item = get_mysql_data('SELECT * FROM my_table WHERE id=' . $_GET['id']);
?>
<html>
<head>
<title><?php echo $item['title'];?></title>
</head>
<body>
<table>
<?php
$users = get_mysql_data('SELECT * FROM users WHERE bla = '.$item[ 'id2'] );
?>
<?php for($i=0; $i< count($users);$i++){ ?>
<tr><td><?php echo $users[$i]['username'] ?></td></tr>
<?php } ?>
</table>
</body>
</html>
<?php
namespace Orim\Payment\Models;
use Orim\Payment\Interfaces\PaymentInterface;
class CreditCard implements PaymentInterface
{
/*
* Some comment
*/
protected $veryImportantDependency;
public function __construct ( $dependency ){
$this->veryImportantDependecy = $dependecy;
}
public function doSomething(){
...
}
private function calculateSomething(){
...
}
}
?>
<!DOCTYPE html> <html> <head> <title>My Webpage</title> </head> <body> <ul id="navigation"> {% for item in navigation %} <li><a href="{{ item.href }}">{{ item.caption }}</a></li> {% endfor %} </ul> <h1>My Webpage</h1> {{ a_variable }} </body> </html>
Example taken from Twig
(http://twig.sensiolabs.org/doc/templates.html)
{% extends "base.html" %} {% block navigation %} <ul id="navigation"> {% for item in navigation %} <li> <a href="{{ item.href }}"> {% if 2 == item.level %} {% endif %} {{ item.caption|upper }} </a> </li> {% endfor %} </ul> {% endblock navigation %}Example from Wikipedia about Twig
(http://en.wikipedia.org/wiki/Twig_%28template_engine%29)
PHP Renaissance
Miro Svrtan
@msvrtan
About me
PHP developer (14~15 years)
Working as Njuskalo.hr Technical Analyst
In spare time
one of ZgPHP organizers
& one of WebCamp Zagreb organizers
PHP_version_milestones
PHP 1 - 1995
PHP 3 - 1998 - popularity gained
PHP 4 - 2000 - wannabe objectz
PHP 5 - 2004 - OO support
PHP 5.3 - 2009
PHP 5.4 - 2012
PHP 5.5 - 2013
PHP 6 - Never ever ever??
JavaScript
VoxPopuli
Have you used PHP before but switched?
Only vanilla PHP?
Used some inhouse/self built library/framework?
Used some community driven fw?
Competition
Headstart
1 Language ~ 1 framework
Diversity
CakePHP
CodeIgniter
Kohana
Laravel
Phalcon
Silex
Symfony 1 & 2
Yii
Zend 1 & 2
... and many more ...
Stats by Google Trends 2012
Taken from webcoderpro.com
Stats by jobs
Taken from php.dzone.com
Comparison
PHP vs Django/RoR
Yes Django wins.
Yep you guessed RoR wins.
Wrong comparisons ...
STOP
Pro's & Con's
Con #1: Legacy code
i.e. Mantis Bug Tracker
Fighting some old & dirty legacy code in RL :(
Con #2: Easy to start
Let's you shoot yourself in the foot
Beginners hacking away
Con #3: Language inconsistency
underscores: isset vs is_null
abbreviations: call_user_func vs create_function
parameter orders: in_array($needle, $haystack) vs strpos($haystack, $needle)
Pro #1: RTFM
Great resource manual for almost every function/method on php.net
Years of community effort filled with examples and suggestions
Pro #2: Easy to start
Yep it is pro too
You can see results of your work in minutes
Cheap & widely available hosting
Pro #3: Evolving constantly
language
projects
libraries/frameworks
community
Pro #4: Community
large user and speaker base
numerous conferences
ZgPHP monthly meetups
ZgPHP conference
New generation
Next generation better name?
Maybe "New kids on the block"?
How ever we will call them..
coding format standardization
package managment
Composer - Package & dependency manager
easy to use
slows down reinventing the wheel
improves code re-usability
supports git repos directly
Packagist - package repository
Frameworks
Zend 2
Symfony2
Laravel 4
Silex
Phalcon
Twig
Templating engine
Inspiriran Jinjom i Django templatesima
Ali PHP je templating engine...
Framework Interoperability Group
community organization
29 member projects
suggested PSR-* coding standards
PSR
controversial due to language fragmentation
PSR-0 file/class folder structure
PSR-1 & PSR-2 basic coding standard
PSR-3 logging interface standard
PHAR
similar to JAR
packs whole application in one file
easy distribution
Composer, PHP Unit, PHP CodeSniffer, Behat...
Hosting
Shared
VPS
Dedicated servers
Cloud
Heroku
Google App Engine
Azure
and many many more ....
In the wild
GitHub
Travis CI
Vagrant
Github user comparison
Github repo comparison
Travis CI (12/2012!)
Moar numbers
Even moar numbers
Regional PHP usage
Top 10 by reach, Gemius Audience
Croatia TOP 10
5
Serbia TOP 10
9
Regional PHP usage (2)
Top 10 by reach, Gemius Audience
Bosnia & Herzegovina TOP 10
10
Slovenia TOP 10
7
Questions?
Thank you!
@msvrtan
www.mirosvrtan.me
PHP
By Miro Svrtan
PHP
- 2,033