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.
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.
<?php | |
/** | |
* Return the value for a key in an array or a property in an object. | |
* Typical usage: | |
* | |
* $object->foo = 'Bar'; | |
* echo get_key($object, 'foo'); | |
* | |
* $array['baz'] = 'Bat'; | |
* echo get_key($array, 'baz'); |
{ | |
"shell_cmd": "php \"${file}\"", | |
"working_dir": "${file_path}", | |
"selector": "source.php" | |
} |
<IfModule mod_rewrite.c> | |
RewriteEngine on | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule wp-content/uploads/(.*) http://PRODUCTION_SERVER/wp-content/uploads/$1 [NC,L] | |
</IfModule> |
<?php | |
class AppServiceProvider extends ServiceProvider | |
{ | |
/** | |
* Bootstrap any application services. | |
* | |
* @return void | |
*/ | |
public function boot() |
How to configure phpStorm with EditorConfig and PHPMD: | |
----------------------------------------------------- | |
PHPMD: | |
------ | |
phpmd (PHP Mess Detector) is a static analysis tool that will find issues in your code you never knew you had. Your code will still run, follow a few of phpmd's recommendations though and it will be better! | |
phpmd is already bundled and enabled in phpstorm, but in order to more easily manage versions and add custom rulesets, you should do the following: |
<?php | |
namespace App\Providers; | |
use Illuminate\Routing\Router; | |
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; | |
class RouteServiceProvider extends ServiceProvider | |
{ | |
/** |
Collection::macro('transpose', function () { | |
$items = array_map(function (...$items) { | |
return $items; | |
}, ...$this->values()); | |
return new static($items); | |
}); | |
public function store(Request $request) | |
{ |