A curated list of amazingly awesome PHP libraries, resources and shiny things.
- Composer/Packagist - A package and dependency manager.
- Composer Installers - A multi framework Composer library installer.
A curated list of amazingly awesome PHP libraries, resources and shiny things.
<?php | |
class MyModel extends Eloquent { | |
public function getSql() | |
{ | |
$builder = $this->getBuilder(); | |
$sql = $builder->toSql(); | |
foreach($builder->getBindings() as $binding) | |
{ |
/** | |
* Simple PHP function to split text by given number of sentences with given length each. | |
* | |
* @param string $long_string String of text | |
* @param int $max_length Maximum length of each sentence. Default: 150 | |
* @param int $max_sentences Maximum number of sentences to return. Default: 10 | |
* @param string $encoding Encoding of input string. Default: 'UTF-8' | |
* | |
* @return array | |
*/ |
#!/bin/bash | |
# Gist: 11375877 | |
# Url: https://gist.github.com/goodevilgenius/11375877 | |
# | |
# All memcache functions are supported. | |
# | |
# Can also be sourced from other scripts, e.g. | |
# source membash.sh | |
# MCSERVER="localhost" |
Magic words:
psql -U postgres
Some interesting flags (to see all, use -h
or --help
depending on your psql version):
-E
: will describe the underlaying queries of the \
commands (cool for learning!)-l
: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)#!/bin/sh | |
# Writes an APR1-format password hash to the provided <htpasswd-file> for a provided <username> | |
# This is useful where an alternative web server (e.g. nginx) supports APR1 but no `htpasswd` is installed. | |
# The APR1 format provides signifcantly stronger password validation, and is described here: | |
# http://httpd.apache.org/docs/current/misc/password_encryptions.html | |
help (){ | |
cat <<EOF | |
Usage: $0 <htpasswd-file> <username> |
<?php | |
// https://gist.github.com/magnetikonline/650e30e485c0f91f2f40 | |
class DumpHTTPRequestToFile { | |
public function execute($targetFile) { | |
$data = sprintf( | |
"%s %s %s\n\nHTTP headers:\n", | |
$_SERVER['REQUEST_METHOD'], | |
$_SERVER['REQUEST_URI'], | |
$_SERVER['SERVER_PROTOCOL'] |
<?php | |
/** | |
* Various configurations of Monolog and Whoops | |
* using a Pimple Container as service locator | |
* | |
* Monolog: https://github.com/Seldaek/monolog | |
* Pimple: https://github.com/fabpot/Pimple | |
* Whoops: https://github.com/filp/whoops | |
* Swift Mailer: https://github.com/swiftmailer/swiftmailer |