Skip to content

Instantly share code, notes, and snippets.

View RobinBastiaan's full-sized avatar

Robin Bastiaan RobinBastiaan

View GitHub Profile
@RobinBastiaan
RobinBastiaan / script
Created July 12, 2024 11:35
Boilerplate for creating a Shell Script
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
if [[ "${1-}" =~ ^-*h(elp)?$ ]]; then
@RobinBastiaan
RobinBastiaan / Info for PHPStorm.md
Created November 24, 2022 20:46 — forked from Pen-y-Fan/Info for PHPStorm.md
PHPStorm Tips, Tricks and setup

PHPStorm

PhpStorm Tips, ticks and standard setup

  1. Tips and Tracks for PHPStorm (PHPStorm Tips and Tricks.md)
  2. Standard setup for PHP projects (Standard.md)
@RobinBastiaan
RobinBastiaan / config.php
Created November 8, 2022 21:56 — forked from jarektkaczyk/config.php
Laravel - tinker like a boss (with PsySH)
<?php // ~/.config/psysh/config.php
// Anything not Laravel - let's try to autoload something likely to exist
if (!defined('LARAVEL_START')) {
return [
'defaultIncludes' => [
getcwd().'/vendor/autoload.php',
getcwd().'/bootstrap/autoload.php',
],
];
# Laravel Best Practices
Laravel is a PHP framework and just like any other PHP framework there are several ways to get a single thing done in a lot of cases, for conformity these are hand picked best practices.
1. Installation of every Laravel project should be done with:
```bash
composer create-project laravel/laravel {./} or {projectname-backend}
```
2. The project name should be in kebab cases in the format: `{projectname-backend}`
3. All file names should be in title cases **ProductController, PostService, Category**
4. All services should be named after model name if tied to a model, else it should carry the name of the entity, and the suffix 'Service' i.e. {Name}Service
@RobinBastiaan
RobinBastiaan / class-order.php
Created August 18, 2022 12:13 — forked from hkdobrev/class-order.php
PHP convention for the order in a class.
<?php namespace Vendor\Library;
use Another\Vendor\Library\ClassName;
abstract class ClassName extends AnotherClass implements Countable, Serializable
{
const CONSTANTS = 'top';
use someTrait, anotherTrait {
anotherTrait::traitMethod insteadof someTrait;

Configuration & Aliases

Various configuration and alias commands you can directly run from the command line.

Aliases are convenient shotcuts making your everyday work a little easier. This is especially true for commands that you use a lot and thus save you a lot of keystrokes, and for commands that are so long making them hard to remember and tidious to type. When designing an alias I make sure the abbreviation makes sence to me. In that way they are not too cryptic and makes sure I remember them more easily. I try to use the following methodology:

  • First, I abbriviate git commands with a 2 character representation. If there is a clash with another command, some opinionated judgement is needed to decide the most logical resolution.
  • To extend these basic abbriviations, I add a 3rd character to include some flags. Or maybe a 4th to extend these even more.
  • Then, for the most used commands (possibly with flags), I will make a 1 character representation. These are quick wins!
  • Lastly, there are some