Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
upstream php-fpm { | |
server unix:/var/run/php5-fpm.sock; | |
} | |
server { | |
listen 80; | |
server_name www.example.com; | |
rewrite ^ http://example.com$request_uri?; | |
} |
Awesome PHP has been relocated permanently to its own Github repository. No further updates will made to this gist.
Please open an issue for any new suggestions.
These examples are type 3 RESTful API requests and responses. The JSON-HAL specification is used to implement HATEOAS.
Some of the examples are based on my work as architect of the RESTful API at http://www.hautelook.com. All proprietary information has been removed.
# Nginx+Unicorn best-practices congifuration guide. Heartbleed fixed. | |
# We use latest stable nginx with fresh **openssl**, **zlib** and **pcre** dependencies. | |
# Some extra handy modules to use: --with-http_stub_status_module --with-http_gzip_static_module | |
# | |
# Deployment structure | |
# | |
# SERVER: | |
# /etc/init.d/nginx (1. nginx) | |
# /home/app/public_html/app_production/current (Capistrano directory) | |
# |
# Please paste to folder common/common.conf | |
index index.html index.htm; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
#location ~ \.(js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ { } |
<?php | |
use \Nette\Utils\Json; | |
/** | |
* Minimalistic Google OAuth2 connector | |
* @author Mikuláš Dítě | |
* @license BSD-3 | |
*/ | |
class Google extends Nette\Object |
The [RFC for a new simple to use password hashing API][rfc] has just been accepted for PHP 5.5. As the RFC itself is rather technical and most of the sample codes are something you should not use, I want to give a very quick overview of the new API:
Everybody knows that you should be hashing their passwords using bcrypt, but still a surprising number of developers uses insecure md5 or sha1 hashes (just look at the recent password leaks). One of the reasons for this is that the crypt() API is ridiculously hard to use and very prone to programming mistakes.
<?php | |
require_once('./vendor/autoload.php'); | |
use Kwattro\Neo4jClient; | |
$bclient = new Neo4jClient(); | |
$client = $bclient->getClient(); | |
$request = $client->get('/db/data'); | |
$response = $request->send(); |
<?php | |
/** | |
* Třída existuje, aby se vůbec neukládala session, tam kde není potřeba. | |
* Například v API, nebo v Cronu se různě sahá na session, i když se reálně mezi requesty nepřenáší. | |
* | |
* @internal | |
*/ | |
class ArraySessionStorage extends Nette\Object implements Nette\Http\ISessionStorage | |
{ |