Skip to content

Instantly share code, notes, and snippets.

@stillfinder
stillfinder / create_laravel_app.sh
Last active May 21, 2019 12:37
Create Laravel application
#!/bin/bash
laravel new $1
cd $1
cp ../_ide_helper.php .
cp .env.example .env
composer install
yarn install
php artisan key:generate
@stillfinder
stillfinder / create_laravel_app_valet.sh
Last active January 10, 2019 16:46
Install new Laravel project in Valet parked directory. (Setup DB, composer & yarn, create git repo)
#!/bin/bash
laravel new $1
cd $1
cp ../_ide_helper.php .
cp .env.example .env
composer install
yarn install
php artisan key:generate
@stillfinder
stillfinder / LocalValetDriver.php
Last active November 27, 2018 04:12
Drupal + Valet
<?php
class LocalValetDriver extends ValetDriver
{
/**
* Determine if the driver serves the request.
*
* @param string $sitePath
* @param string $siteName
* @param string $uri
@stillfinder
stillfinder / frontControllerPath.php
Last active November 27, 2018 04:10
Drupal Valet ?q parameter
<?php
public function frontControllerPath($sitePath, $siteName, $uri)
{
$sitePath = $this->addSubdirectory($sitePath);
if (!isset($_GET['q']) && !empty($uri) && $uri !== '/') {
$_GET['q'] = $uri;
}
@stillfinder
stillfinder / LocalValetDriver-q-hack.php
Created November 27, 2018 04:08
LocalValetDriver ?q hack
<?php
if (!isset($_GET['q']) && !empty($uri) && $uri !== '/' && strpos($uri, '/jsonapi/') === false) {
$_GET['q'] = $uri;
}
@stillfinder
stillfinder / SearchController.php
Created November 29, 2018 23:40
SearchController.php
<?php
namespace Drupal\custom_api\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Class SearchController.
*/
class SearchController extends ControllerBase {
@stillfinder
stillfinder / custom_api.routing.yml
Created November 29, 2018 23:41
custom_api.routing.yml
custom_api.search:
path: 'custom_api/search/{search}'
defaults:
_controller: '\Drupal\custom_api\Controller\SearchController::search'
_title: 'ControllerMethod'
requirements:
_permission: 'access content'
@stillfinder
stillfinder / generate-controller.sh
Last active November 30, 2018 09:18
generate-controller.sh
../vendor/bin/drupal generate:controller --module=custom_api --class=SearchController --routes='"title":"ControllerMethod", "name":"custom_api.search", "method":"search", "path":"custom_api/search/{search}"' --uri=my-site.com
# Git aliases
alias gb="git branch"
alias gaa="git add ."
alias gc="git commit -a -m"
alias gs="git status"
alias nah="git reset --hard; git clean -df;"
@stillfinder
stillfinder / .gitconfig
Last active December 11, 2018 12:35
gitconfig aliases
[alias]
co = checkout
s = status
l = log
url = config --get remote.origin.url