Current state-of-php
-
Upload
richard-mcintyre -
Category
Technology
-
view
429 -
download
0
Transcript of Current state-of-php
Current State of PHP
Richard McIntyre
About me→ PHPer
→ JavaScripter→ Rubyist→ Other
→ Contributer to Lithium #Li3 and BEAR.Sunday frameworks
→ Author of Spout CMS and ShouldIT?
PHP History
Organically grown
PHP 3Objects
What year?
1998
PHP 4Zend Engine
2000
PHP 5.3Namespaces Lamdas / Closures
2009
Projects became messy!
O'Reilly BLog
Embedding PHP in regular HTMLIf you have been paying attention to our earlier
articles, you hopefully have picked up on how PHP can be embedded into a regular HTML document. For example, we should already know that the following
is an example of how PHP is embedded:
<html><head><title>My first PHP Page</title></head><body>This is normal HTML code<?php
// php code goes here?>
Back into normal HTML
</body></html>
<?php// database connection stuff hereif (!isset($screen)) $screen = 0;$start = $screen * $rows_per_page;$sql = "SELECT description FROM table_name ";$sql .= "LIMIT $start, $rows_per_page";$result = mysql_query($sql, $db);$rows = mysql_num_rows($result);for ($i = 0; $i < $rows; $i++) { $description = mysql_result($result, $i, 0); echo "\$description = $description<br>\n";}echo "<p><hr></p>\n";// let's create the dynamic links nowif ($screen > 0) { $url = "example.php?screen=" . $screen - 1; echo "<a href=\"$url\">Previous</a>\n";}// page numbering links nowfor ($i = 0; $i < $pages; $i++) { $url = "example.php?screen=" . $i; echo " | <a href=\"$url\">$i</a> | ";}if ($screen < $pages) { $url = "example.php?screen=" . $screen + 1; echo "<a href=\"$url\">Next</a>\n";}?>
The answer!Frameworks
Too many frameworks!
Best Practices
Testing
Design Patterns
Composer
What about JS?
The hipster thing to do
Rich User Experiences
Long running processes
Functional Programming
Isomorphic Applications
We can do everything in this
But...
Fragile tooling
Messy applications
Competing async models
export default (filesMap) => { return new Promise((resolve, reject) => { let filePromises = []; for (let name of Object.keys(filesMap)) { filePromises.push(readFile(filesMap[name])); } Promise .all(filePromises) .then((filesData) => { resolve(filesData.reduce((prev, curr) => prev += curr)); }, reject); });};
Devs are scarce
What is great about PHP
Mature
Build Businesses on IT
Community
Elegant coding implementations
<?php
namespace App\Http\Controllers;
use App\Repositories\UserRepository;
class UserController extends Controller{ /** * The user repository instance. */ protected $users;
/** * Create a new controller instance. * * @param UserRepository $users * @return void */ public function __construct(UserRepository $users) { $this->users = $users; }}
Throwaway request response lifecycle
A faster and improved PHP
Uniform Variable Syntax ($object->closureProperty)();
Uniform Variable Syntaxclass foo { static $bar = 'baz'; }class baz { static $bat = 'Hello World'; }
baz::$bat = function () { echo "Hello World"; };
$foo = 'foo';($foo::$bar::$bat)();
Return Typesfunction isValidStatusCode(int $statusCode): bool { return isset($this->statuses[$statusCode]);}
Amazing PHP Projects
Ray.DI
ORM
FastRoute
PHPMailer
Codeception
Prophecy
So....Should I use? PHP or JS?
What does your Stack look like?
What kind of processing do you want to do?
Sometimes there is an
even better fit?
Do you need it to be a single page app?
Are you an agency?
Enterprise→ Java→ .net
Enterprise→ Java→ .net→ PHP
On what tools do you think you can build your empire?
Use both?!
Take-home Challenge
ThanksQuestions@mackstar