Grzegorz Murdzek Twitter: @grxmrx
WebDNA.io narzędzie SEO do klasyfikacji linków
machine learning
Polski Portal Amigowy PPA.pl Polskie Pismo Amigowe Decrunch.org
komputery Amiga, systemy AmigaOS i MorphOS
Rozbudowa języka (1/2)• klasy, interfejsy, wyjątki
• Standard PHP Library (jako baza dla iteratorów, nowych typów, wyjątków i interfejsów)
• namespaces
• traits
• generators
Rozbudowa języka (2/2)• wbudowany webserver
• funkcje anonimowe
• funkcje o zmiennej liczbie argumentów
• funkcje do haszowania haseł
• PHP-FPM
Prehistoria<!--include /text/header.html-->
<!--sql database select * from table where user='$username'-->
<!--ifless $numentries 1-->
Sorry, that record does not exist<p>
<!--endif exit—>
<!--include /text/footer.html-->
Stare dzieje przykład antywzorca
<?php include("include/{$page}.inc"); ?>
<html>
<title><?php echo $title; ?></title>
<?php
function fetch_article($bar) {
global $title;
$result = mysql_query("SELECT * FROM articles WHERE a=$_GET[id]");
if($bar==12 && $result && $title!=null) {
return mysql_fetch_row($result);
}
?>
<body>
<blink><? echo '<p>' . $title . '</p>'; ?></blink>
Deprecated• register globals, magic_quotes, safe_mode
• rozszerzenie mysql
• funkcje require() lub include() ładujące funkcje, klasy lub wszelkie inne kawałki kodu „na wszelki wypadek”
• problematyczne __autoload() i inne magiczne metody
• przeładowane ścieżkami include_path
Kilka lat temu Kohana
<?php defined('SYSPATH') OR die('No direct access allowed.'); class Album_Controller extends Controller { private $album_model; private $genre_model; private $list_view; private $create_view; private $update_view; public function __construct() { parent::__construct(); $this->album_model = new Album_Model; $this->genre_model = new Genre_Model; $this->list_view = new View('list'); $this->update_view = new View('update'); $this->create_view = new View('create'); } public function index() { $this->show_albums_list(); } private function show_albums_list() { $albums_list = $this->album_model->get_list(); $this->list_view->set('albums_list',$albums_list); $this->list_view->render(TRUE); }
Dzisiaj Symfony 2
<?phpnamespace WebDNA\Bundle\AppBundle\Controller;use Symfony\Bundle\FrameworkBundle\Controller\Controller;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;use Symfony\Component\HttpFoundation\Request;use WebDNA\Bundle\AppBundle\Entity\Website;/** * Class DashboardController * * @Route("/dashboard") */class DashboardController extends BaseController{ /** * @Route("/id/{website}", name="dashboard_website") * @Template() */ public function indexAction(Request $request, Website $website)
{
$websiteService = $this->get('websites');
/* … */ if (!$website) { throw new NotFoundResourceException();}
return ["website" => $website];
}
Dzisiaj Slim framework
<?php
require 'vendor/autoload.php';
$app = new \Slim\Slim(); $app->get('/books/:id', function ($id) use ($app) { $app->render('show.php', array('title' => 'Sahara')); });
$app->run();
„Haters gonna hate”• phpwtf.org
• phpsadness.com
• eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design
• quaxio.com/wtf/php.html
• wiki.theory.org/YourLanguageSucks#PHP_sucks_because
„Personal Home Page”• łatwy próg wejścia
• szybkie wdrożenia małych projektów
• wiele możliwości aktualizacji aplikacji
• „odświeżam i widzę, że działa”
• język jako system szablonów
• tani hosting
Atuty• duży wybór frameworków i microframeworków
• język start-upów
• szybkie GTD
• baza bibliotek i dodatków
• duża społeczność aktywna na GitHubie
Kto to ogarnia?
• duża liczba osób o niskich kwalifikacjach
• wyższe zarobki dla specjalistów konkurencyjnych języków, ale więcej ofert dla PHP
• spory dług technologiczny popularnych projektów
• niekonsekwencje w samym języku, na które trzeba uważać
PHP: The Right Way www.phptherightway.com
• PHP-FIG, standard PSR
• Composer
• PDO, Doctrine ORM
• PHPUnit, Behat
• XDebug, XHProf
• Symfony 2, Zend Framework 2, Laravel
PHP 7• return types
• znacznie poprawiona prędkość działania silnika https://nikic.github.io/2014/12/22/PHPs-new-hashtable-implementation.html
• JIT
• asynchroniczność
• scalar type hints?
PHP 7 w testach benchmark 12 lutego 2015
0
100ms
200ms
300ms
400ms
PHP7-JIT (JIT=on)HHVM-3.5.0 (JIT=on)
PHP 5.6
PHP 5.5
PHP 5.4
https://gist.github.com/dstogov/12323ad13d3240aee8f1