Setup
$ composer install
$ php -S localhost:8000
Version 1.0 call:
curl -X "GET" "http://localhost:8000/index.php/foo" -H "Accept: 1.0"
Setup
$ composer install
$ php -S localhost:8000
Version 1.0 call:
curl -X "GET" "http://localhost:8000/index.php/foo" -H "Accept: 1.0"
#!/usr/bin/env bash | |
# Be sure to install the apiary gem; https://github.com/apiaryio/apiary-client | |
# gem install apiary | |
# You'll need to get a token here; https://login.apiary.io/tokens | |
APIARY_API_KEY= | |
# Your apiname here; docs.$APINAME.apiary.io | |
APINAME= |
<?php | |
trait EventGenerator | |
{ | |
protected $pendingEvents = array(); | |
protected function raise($event) | |
{ | |
$this->pendingEvents[] = $event; | |
} |
git branch -m old_branch new_branch # Rename branch locally | |
git push origin :old_branch # Delete the old branch | |
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant.configure("2") do |config| | |
config.vm.box = "precise32" | |
config.vm.box_url = "http://files.vagrantup.com/precise32.box" | |
config.vm.network :forwarded_port, guest: 3000, host: 3000 | |
config.vm.hostname = "ruby-dev-server" | |
config.vm.provision :shell, path: "install.sh" |
This is just a small post in response to [this tweet][tweet] by Julien Pauli (who by the way is the release manager for PHP 5.5). In the tweet he claims that objects use more memory than arrays in PHP. Even though it can be like that, it's not true in most cases. (Note: This only applies to PHP 5.4 or newer.)
The reason why it's easy to assume that objects are larger than arrays is because objects can be seen as an array of properties and a bit of additional information (like the class it belongs to). And as array + additional info > array
it obviously follows that objects are larger. The thing is that in most cases PHP can optimize the array
part of it away. So how does that work?
The key here is that objects usually have a predefined set of keys, whereas arrays don't: