For Package Development

Image for post
Image for post

A workbench is a project dedicated for creating all your packages.

First step

The first step that needs to be taken, is cloning Laravel. Go to your code directory and run git clone git@github.com:laravel/laravel.git. Your workbench directory will now be called laravel. The location of my workbench is ~/Server/laravel.

Packages folder

Within your workbench you need a directory for your packages. We are going to use this directory to autoload the packages you are creating. For your package you can create directories with the following structure: packages/[Vendor]/[Package]/src. This could result in packages/Captain/Awesome/src.

Composer.json

Navigate to you package (packages/Captain/Awesome/src) and run composer init. …


CLI Commands on Steroids

Image for post
Image for post

When working with Laravel, you have to use your CLI tool pretty much. I found I was running long commands several times, so I made some handy aliases for them, to quickly run long commands with small abbreviations.

The CLI tool I use is iTerm with Oh My Zsh. Especially Oh My Zsh adds a lot of awesomeness. One I like to most is that you don’t have a capitalize folders and files in the CLI, just hit tab, and the folder or file name will be completed.

Aliases

  • alias art='php artisan'

I know some people have other aliases for php artisan. My friends use part (p[hp] art[isan]). And Freek van der Herten made the alias the smallest possible: a. …


Image for post
Image for post

View Composers are very handy when you’re including partials on multiple pages. It will ensure the variables used in the partial, are always set, so you won’t get errors like variable not set.

How do View Composers work?

View Composer are created within a Service Provider, and best practice is to create a dedicated Service Provider, called ComposerServiceProvider. Within the boot method, call this code to register a simple View Composer.

view()->composer('header', function ($view) {
$view->with([
'message' => 'This is a message on some page'
]);
});

In this example we’ll push the variable $message to a partial called header.

About

Gijs Jorissen

Web Developer. ❤ Laravel, Wordpress, Vue.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store