Reputation: 672
I've noticed a (to me) weird pattern that Laravel Spark is using to install itself and I cannot really figure out as why this should be done or is being considered good practice.
Given we create a Spark application in directory /var/acme-spark
.
First, the Spark installer sets up a Laravel application. After that, it downloads/installs all Spark files (PHP source code, frontend assets, such as LESS and JS files, blade templates and whatnot) into a directory called spark
in project root, i.e. into /var/acme-spark/spark
. It then updates composer.json
to contain the following:
{
// ...
require: {
// ...
"laravel/spark": "*@dev"
}
// ...
"repositories": [
{
"type": "path",
"url": "./spark"
}
]
}
Which basically means: "Take the spark
directory and treat it as a vendor repository. Then create a symlink for the spark
directory within vendors."
The symlink indeed looks like the following:
user@machine:~$ cd /var/acme-spark/vendor/laravel
user@machine:/var/acme-spark/vendor/laravel$ ls -l
cashier
framework
homestead
spark -> ../../spark
Now this is puzzling, since it gives you full control over everything that is Spark core, so why use composer at all? On the other hand, it makes updating an issue, since you might have changed things and expect them to not being overwritten during an update. So why not use a simple composer package with a private repository then?
Why is it done the way it is? Is it good practice or not? What are the reasons for it being or not being good practice?
Upvotes: 3
Views: 548
Reputation: 701
Spark its not a composer package as its a premium feature, because of this you must add the repo somewhere and this way composer its able to find it and install like a normal composer package. Spark update itself so the manteinability its done by the artisan command.
About good practice, how you architect your files does not matter if at the end works, this has no performance issues and things can be done in different ways.
In conclusion, the reason about this its because you can't download spark directly from composer.
Upvotes: 3