Skip to content

Instantly share code, notes, and snippets.

@lucasdavies
lucasdavies / routing_patterns.php
Created February 25, 2014 08:24
Routing patterns from laravel-tricks.com
<?php
// This is what you might have right now
Route::get('users/{id}', 'UserController@getProfile')->where('id', '[\d+]+');
Route::get('products/{id}', 'ProductController@getProfile')->where('id', '[\d+]+');
Route::get('articles/{slug}', 'ArticleController@getFull')->where('slug', '[a-z0-9-]+');
Route::get('faq/{slug}', 'FaqController@getQuestion')->where('slug', '[a-z0-9-]+');
// and many more, now imagine you'll have to change the rule
// Instead, you could have a handy list of patterns and reuse them everywhere:
@lucasdavies
lucasdavies / .bashrc
Last active April 20, 2016 08:45
Bash aliases
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias chmod='chmod -c'
alias cl="clear"
alias vi="vim"
alias ll="ls -lah"
alias llr="ls -lahtr"
alias ..="cd ../"
@lucasdavies
lucasdavies / UserRepository.php
Last active October 20, 2016 10:15
Example of a Service Locator
<?php
class UserRepository
{
public function __construct(Container $container)
{
$this->container = $container;
}
public function getUser($id)