Laravel Development with Vessel (Docker)

Getting started with Vessel

I have started using Vessel for my local development as it makes starting and developing a project so much easier. It seems more lightweight than Homestead and the start-up time is much quicker than Homestead.

No PHP or Composer? No problem

If you don’t have PHP7 or Composer installed on your machine, you can follow these instructions to help get you started. It will install PHP7 and Composer environments with Docker and allowing you to create a Laravel project and install Vessel as a package.

I also add /docker folder into my .gitignore as vessel will create this upon initialisation. You could also ignore the vessel and docker-compose.yml files as well, but I enjoy keeping it within my projects.

Bash Commands

Vessel is a bash file and allows you to run any artisan, yarn or npm command of your choosing which makes it easier rather than ssh’ing into a homestead box or running the exec command.

Only for development environments

It has fantastic documentation and should allow you to get running within 10 minutes. The only downside to Vessel is that it’s only for development work and not production. So don’t expect Lets Encrypt certificates or deployment strategies with this.

Want to learn more about going from Development to Deployment? I will be live streaming a learning event Laravel: from development to deployment

If you enjoyed this article, please follow for more. Alternatively, you can Buy me a coffeeBuy me a coffee

 

Composer Private Repository Problems

Composer

Cross development can be a pain…

Recently I have been finding out the slight differences between Windows and Linux for use with Laravel and Composer. One difference is Windows isn’t picky about the way you set out Composer’s packages which can be a major problem. Here’s the issue I had and what I had to do to get it going…

{
	"name": "laravel/laravel",
	"description": "The Laravel Framework.",
	"keywords": ["framework", "laravel"],
	"license": "MIT",
	"repositories": [
		{
			"type": "vcs",
			"url": "[email protected]:mbrookspulse8/admin.git",
			"url": "[email protected]:pulse8/haulfryn-admin-sliders.git",
			"url": "[email protected]:pulse8/haulfryn-admin-parks.git",
			"branches-path": false,
			"tags-path": false
		}
	],
	"require": {
		"laravel/framework": "4.1.*",
		"cartalyst/sentry": "2.1.*",
		"imagine/Imagine": "0.5.0",
		"edvinaskrucas/notification": "2.*",
		"way/generators": "dev-master",
		"pulse8/admin": "dev-master",
		"pulse8/sliders": "dev-master",
		"pulse8/parks": "dev-master",
		"geedmo/yamm3": "dev-master"
	},
	"autoload": {
		"classmap": [
			"app/commands",
			"app/controllers",
			"app/models",
			"app/database/migrations",
			"app/database/seeds",
			"app/tests/TestCase.php"
		]
	},
	"scripts": {
		"post-install-cmd": [
			"php artisan clear-compiled",
			"php artisan optimize"
		],
		"post-update-cmd": [
			"php artisan clear-compiled",
			"php artisan optimize"
		],
		"post-create-project-cmd": [
			key:generate"
		]
	},
	"config": {
		"preferred-install": "dist"
	},
	"minimum-stability": "stable"
}

As you can see, I placed all of my private VPS URLs into one JSON object. On Windows, everything was fine and dandy, nothing was overwritten and everything could be found easily. However, when I placed it all on the server, this is where I ran into problems. Linux is more strict on standards (which is definitely not a bad thing) and caused a lot of aches and pains for me as I wasn’t coding to these standards. It took me and my team a whole day to suss out what was wrong, but this was our finished code for the private VPS URLs…

"repositories": [
	{
		"type": "vcs",
		"url": "[email protected]:mbrookspulse8/admin.git",
		"branches-path": false,
		"tags-path": false
	},
	{
		"type": "vcs",
		"url": "[email protected]:pulse8/haulfryn-admin-sliders.git",
		"branches-path": false,
		"tags-path": false
	},
	{
		"type": "vcs",
		"url": "[email protected]:pulse8/haulfryn-admin-parks.git",
		"branches-path": false,
		"tags-path": false
	}
],

They have been separated into their own object and now runs perfectly fine on Windows and Linux. Had similar issues? If so then please feel free to share and let me know how you overcame them.