<?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
Miro Svrtan
@msvrtan
PHP developer (14~15 years)
Working as Njuskalo.hr Technical Analyst
In spare time
one of ZgPHP organizers
& one of WebCamp Zagreb organizers
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??
Have you used PHP before but switched?
Only vanilla PHP?
Used some inhouse/self built library/framework?
Used some community driven fw?
Headstart
1 Language ~ 1 framework
CakePHP
CodeIgniter
Kohana
Laravel
Phalcon
Silex
Symfony 1 & 2
Yii
Zend 1 & 2
... and many more ...
PHP vs Django/RoR
Yes Django wins.
Yep you guessed RoR wins.
Wrong comparisons ...
STOP
i.e. Mantis Bug Tracker
Fighting some old & dirty legacy code in RL :(
Let's you shoot yourself in the foot
Beginners hacking away
underscores: isset vs is_null
abbreviations: call_user_func vs create_function
parameter orders: in_array($needle, $haystack) vs strpos($haystack, $needle)
Great resource manual for almost every function/method on php.net
Years of community effort filled with examples and suggestions
Yep it is pro too
You can see results of your work in minutes
Cheap & widely available hosting
language
projects
libraries/frameworks
community
large user and speaker base
numerous conferences
ZgPHP monthly meetups
ZgPHP conference
easy to use
slows down reinventing the wheel
improves code re-usability
supports git repos directly
Zend 2
Symfony2
Laravel 4
Silex
Phalcon
Templating engine
Inspiriran Jinjom i Django templatesima
Ali PHP je templating engine...
community organization
29 member projects
suggested PSR-* coding standards
controversial due to language fragmentation
PSR-0 file/class folder structure
PSR-1 & PSR-2 basic coding standard
PSR-3 logging interface standard
similar to JAR
packs whole application in one file
easy distribution
Composer, PHP Unit, PHP CodeSniffer, Behat...
Shared
VPS
Dedicated servers
Heroku
Google App Engine
Azure
and many many more ....
GitHub
Travis CI
Vagrant
Travis CI (12/2012!)
Moar numbers
Top 10 by reach, Gemius Audience
Croatia TOP 10
5
Serbia TOP 10
9
Top 10 by reach, Gemius Audience
Bosnia & Herzegovina TOP 10
10
Slovenia TOP 10
7
@msvrtan
www.mirosvrtan.me