Skip to content

Instantly share code, notes, and snippets.

@JeffreyWay
JeffreyWay / PjaxMiddleware.php
Last active November 6, 2024 14:26
Laravel middleware for working with pjax.
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Symfony\Component\DomCrawler\Crawler;
class PjaxMiddleware
@msankhala
msankhala / laravel-multiple-env-setup.php
Last active February 29, 2024 04:53
Setup Multiple Environment for Laravel 5 Developers Way
<?php
/*
|--------------------------------------------------------------------------
| Follow this instructions:
|--------------------------------------------------------------------------
|
| Laravel takes a dead simple approach to your application environments
| so you can just specify a machine name for the host that matches a
| given environment, then we will automatically detect it for you.
@carbontwelve
carbontwelve / usefull_commands.sh
Last active June 24, 2021 06:10
Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
# Running xdebug in the console, for debugging Laravel artisan commands. Useful as I keep forgetting this one...
php -dxdebug.remote_autostart artisan
#Running phpcs for 5.3:
phpcs -pv --standards= --runtime-set testVersion 5.3 --ignore=*/public/*,*.js,*.css,*/tests/*,*/views/training/* .
@messified
messified / php-interview.md
Last active July 1, 2024 05:15
PHP Engineer Interview: What you should know

PHP Developer Interview: What you should know

1. What’s the difference between " self " and " this " ?

Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members.

Source: When to use self vs this -stackoverflow

class BaseModel extends \lithium\data\Model {
public static function create(array $data = array(), array $options = array()) {
$defaults = array('defaults' => true, 'class' => 'entity');
$options += $defaults;
$model = get_called_class();
if (isset($data['_type']) && $data['_type']) {
list($namespace, $name) = preg_split("/\\\[^\\\]*$/", $model);
$model = $namespace . '\\' . Inflector::humanize(Inflector::pluralize($data['_type']));
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active April 20, 2025 23:00
A badass list of frontend development resources I collected over time.
@marcghorayeb
marcghorayeb / gist:5644257
Last active December 17, 2015 17:09
Filter Lithium's SQL describe method so that the schema can be cached and retrieved quickly
<?php
// I have this in my bootstrap/cache.php file
Dispatcher::applyFilter('run', function ($self, $params, $chain) {
foreach (Connections::get() as $connection) {
$connection = Connections::get($connection);
$connection->applyFilter('describe', function($self, $params, $chain) {
if (!empty($params['fields'])) {
$fields = $params['fields'];
return $self->invokeMethod('_instance', array('schema', compact('fields')));
}
<?php
namespace app\tests\cases\controllers;
use app\controllers\UsersController;
use app\models\Users;
use lithium\action\Request;
use lithium\data\Connections;
class UsersControllerTest extends \lithium\test\Integration {
@murtaugh
murtaugh / 1. single-line.html
Last active April 21, 2021 16:23
Blockquote patterns for ALA
<figure class="quote">
<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote>
</figure>
@P7h
P7h / IntelliJ_IDEA__Perf_Tuning.txt
Last active October 21, 2024 01:10
Performance tuning parameters for IntelliJ IDEA. Add these params in idea64.exe.vmoptions or idea.exe.vmoptions file in IntelliJ IDEA. If you are using JDK 8.x, please knock off PermSize and MaxPermSize parameters from the tuning configuration.
-server
-Xms2048m
-Xmx2048m
-XX:NewSize=512m
-XX:MaxNewSize=512m
-XX:PermSize=512m
-XX:MaxPermSize=512m
-XX:+UseParNewGC
-XX:ParallelGCThreads=4
-XX:MaxTenuringThreshold=1