This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(Input::has('file')) { | |
$file = Input::file('file'); | |
return [ | |
'path' => $file->getRealPath(), | |
'size' => $file->getSize(), | |
'mime' => $file->getMimeType(), | |
'name' => $file->getClientOriginalName(), | |
'extension' => $file->geClientOriginalExtension() | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
header('Status: 404 Not Found'); | |
echo '<html><body><h1>Page Not Found</h1></body></html>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Symfony\Component\HttpFoundation\Request; | |
$request = Request::createFromGlobals(); | |
// the URI being requested (e.g. /about) minus any query parameters | |
$request->getPathInfo(); | |
// retrieve GET and POST variables respectively | |
$request->query->get('foo'); | |
$request->request->get('bar', 'default value if bar does not exist'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Token | |
{ | |
public static function generate() | |
{ | |
return $_SESSION['token'] = base64_encode(openssl_random_pseudo_bytes(32)); | |
} | |
public static function check($token) | |
{ | |
if (isset($_SESSION['token']) && $token === $_SESSION['token']) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Render an exception into an HTTP response. | |
* | |
* @param \Illuminate\Http\Request $request | |
* @param \Exception $e | |
* @return \Illuminate\Http\Response | |
*/ | |
public function render($request, Exception $e) | |
{ | |
if ($e instanceof ModelNotFoundException) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
{ | |
private $bar; | |
private $baz; | |
public function __construct(Bar $bar, Baz $baz) | |
{ | |
$this->bar = $bar; | |
$this->baz = $baz; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DB::enableQueryLog(); | |
App\User::all(); | |
print_r(DB::getQueryLog()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Library implements IteratorAggregate, Countable | |
{ | |
protected $books; | |
public function __construct(array $books) | |
{ | |
$this->books = $books; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Ioc | |
{ | |
protected static $registry = []; | |
public static function bind($name, Callable $resolver) | |
{ | |
static::$registry[$name] = $resolver; | |
} |
OlderNewer