Composer is moving over to use Laravel, which requires command line stuff and a bunch of new thinking as to how code is managed. Also, my bundles have vanished, and now we're using camelCase instead of snake_case? Sit down for a history lesson about why packages have always been a mess, why frameworks have been the way they were and why they're changing in this "PHP Renaissance" to use awesome new tools like Composer.
2. Derp derpy derp!
Kapture PHP The Right Way
PyroCMS PHP Town Hall
CodeIgniter PHP-FIG
FuelPHP I have a weird accent
PancakeApp @philsturgeon
Tuesday, 26 February 13
3. “I could spend 10 minutes
writing some code, but [stuff]
that, I can just install a Gem.”
-- Elliott Kember, RiotHQ
Tuesday, 26 February 13
4. Ruby Gems
Warden - Simple generic authentication
OmniAuth - Integrate Facebook, Twitter, etc
OAuth / OAuth 2 - Go-to gems for oauth
Thor or Clam - Command line frameworks
ActiveRecord - THE ORM for Ruby
Tuesday, 26 February 13
5. Python (PIP)
Requests - THE HTTP class
PIL - Image Manipulation (but doesnt suck)
UJSON - UTF-8 support + way faster
Flask - RESTful micro-framework
PyYAML - Quick YAML parser
Tuesday, 26 February 13
36. Install those Packages
$ ./composer.phar install
Loading composer repositories with package
information
Installing dependencies
- Installing dflydev/markdown (v1.0.2)
Downloading: 100%
....... and so on
Tuesday, 26 February 13
39. Why not just use them?
Boilerplate makes kittens cry
Service Providers + Facade avoid boilerplate
IoC is SIMPLE + Controller integration
Lowest barrier to entry
Tuesday, 26 February 13
42. Where is Laravel 4
https://github.com/laravel/framework
https://github.com/laravel/laravel/tree/develop
https://github.com/illuminate
Tuesday, 26 February 13
44. Install Dependencies
$ cd playground
$ curl -s https://getcomposer.org/installer | php
$ ./composer.phar install
Tuesday, 26 February 13
45. Building a Package
$ php artisan workbench
What is vendor name of the package?Epic
What is the package name?Unicorn
What is your name?Phil Sturgeon
What is your e-mail address?
email@philsturgeon.co.uk
Tuesday, 26 February 13
52. PSR-0
Autoloading Standard
<Vendor Name>(<Namespace>)*<Class Name>
Classes Session_Cache is Session/Cache.php
Must have a top-level namespace
http://bit.ly/PSR-0
Tuesday, 26 February 13
53. PSR-1
Basic Coding Standard
Files are UTF-8
Definition OR side-effect
Constants are upper-case
Class names are StudlyCaps
Method names camelCase()
http://bit.ly/PSR-one
Tuesday, 26 February 13
54. PSR-2
Coding Style Guide
SHOULD limit to 80 or 120 characters per line
All PHP files MUST use the Unix LF (linefeed) line
ending.
The closing ?> tag MUST be omitted from files
containing only PHP.
MUST use 4 spaces for indentation, not tabs
http://bit.ly/PSR-2
Tuesday, 26 February 13
55. Should you PSR-2?
PSR-0 and PSR-1 are no brainers
PSR-2 was split from PSR-1 as its controversial
Tabs v Spaces? I don’t care.
Laravel is PSR-2ish
Tuesday, 26 February 13
58. Framework Driver Basics
interface SessionInterface {
public function getKey();
public function put($value);
public function get();
public function forget();
}
Tuesday, 26 February 13
59. Framework Driver Basics
class NativeSession implements SessionInterface
use CI_Session as Session;
class CISession implements SessionInterface
use FuelCoreSession_Driver as Session;
class FuelPHPSession implements SessionInterface
use IlluminateSessionStore as SessionStore;
class IlluminateSession implements SessionInterface
Tuesday, 26 February 13
60. Framework Driver Basics
use CI_Session as Session;
class CISession implements SessionInterface
{
public function __construct(Session $store)
{
$this->store = $store;
}
}
Tuesday, 26 February 13
61. Framework Driver Basics
public function put($value)
{
$this->store->set_userdata(
$this->getkey(),
serialize($value)
);
}
public function forget()
{
$this->store->unset_userdata(
$this->getKey()
);
}
Tuesday, 26 February 13
65. Any Questions?
What was that thing you said about PSR?
Are you Australian?
Is camelCase web-scale?
Do you prefer Tabs or Spaces?
Why doesn’t PyroCMS support MongoDB?
Tuesday, 26 February 13
66. Thank You
@philsturgeon
philsturgeon.co.uk
github.com/philsturgeon
Tuesday, 26 February 13