Composer and minified version of Nette
- Jan Tvrdík
- Nette guru | 2595
Actually, you CAN download the minified version via Composer. It is important to realize that Composer itself is very often not the limitation, Packagist is. All you need to do is to host your own repository which would contain the minified version.
- David Grudl
- Nette Core | 8218
No need for minified version? Why? I need it.
In fact, for deployment is current Packagist & Composer pain in the ass. I don't like to upload thousands of unnecessary files like examples, tests etc. And there is no way how to use minified version. :-(
- Jan Tvrdík
- Nette guru | 2595
@David Grudl: I still don't understand why having custom repository hosted at nette.org is a problem (its a one hour work to make it work). I'm actually working on my own composer-repository which should solve current problems with Packagist.
- David Grudl
- Nette Core | 8218
One repository hosted at nette.org is not problem, but I don't know how it will solve problems mentioned in my previous post. Could you explain it?
- Jan Tvrdík
- Nette guru | 2595
@David Grudl: You are already building packages for
download, right? So I'm guessing it would be pretty easy to build few more
variants of each package. For example one package with just
composer.json
& nette.minified.php
and another one
with normal version of Nette but without sandbox, examples, tests all all the
other stuff. Once you have the packages ready you to generate one more file –
packages.json
which describes which packages are available. And
that's it =)
packages.json example
{
"packages": {
"nette/nette": {
"2.0.11": {
"name": "nette/nette",
"version": "2.0.11",
"dist": {
"url": "https://files.nette.org/Nette-2.0.11.zip",
"type": "zip"
}
}
},
"nette/nette-minified": {
"2.0.11": {
"name": "nette/nette-minified",
"version": "2.0.11",
"dist": {
"url": "https://files.nette.org/Nette-2.0.11.minified.zip",
"type": "zip"
}
}
}
}
}
The only think I'm not sure is how it would handle dev packages.
- David Grudl
- Nette Core | 8218
Again: I am using various packages. I don't want to upload garbage to server. And I want develop with full Nette and use minified version on server.
How to solve it?
(As solution I am using special rules for deployment script + RobotLoader on server.)
- Jan Tvrdík
- Nette guru | 2595
@David Grudl: I believe this may be possible to solve with
{
"require": {
"nette/nette-minified": "2.0.*"
},
"require-dev": {
"nette/nette": "2.0.*"
}
}
The nette/nette
package would have to contain
something like
"replace": {
"nette/nette-minified": "self.version"
}
I haven't try it though, so it may not work at all.
BTW: How did you solve this problem before Composer-age? You need to somehow replace full Nette with minified version during deployment process.
- David Grudl
- Nette Core | 8218
Before Composer everything was solved manually. It means:
- /libs contained only libraries without unneccessary stuff
- full Nette was replaced with minified one during deployment (rule for deployment script)
- autoloading list was built on server by RobotLoader
In Composer-age:
- /libs containes libraries and a lot of garbage
- full Nette should be replaced with minified as before, but in that case is problem with Composer's autoload
Your solution for nette-minified looks good. I'll try it.
- Jan Tvrdík
- Nette guru | 2595
@David Grudl I was curious so I've tried it myself.
And it doesn't seem to work. Composer installs both packages ignoring the fact
than one replaces another (actually even if you specify them conflicting,
Composer will still install both of them [so it is obviously a bug]). The
workaround I have found is to have nette/nette-minified
as
metapackage which requires the actual nette/nette-minified-real
.
nette/nette
then replaces
nette/nette-minified-real
.
- hrach
- Member | 1838
I agree with Jan Tvrdik. From my point of view it's completely unnecessary to have https://github.com/…tte-minified repo. nette.org package (composer) repository should have do the job.
The thing about garbage:
- Nette itself does not contain these garbage, I install it everywhere by –dist, so it's without tests etc.
- The discussion about minified version does not solve any other issues with other libraries, which have garbage (does not handle this by .gitattributes)
Switching to minified version should me completely managed by deployment, own git deploy solution, dg's ftp deployment, professional solution, etc. Trying to use package manager to do this job is nonsense. The main reason is that php itself has bad dependency design, you cannot use two libs with different versions at once. That's why it will never work same as for other languages (ruby, …).
@dg: In fact, for deployment is current Packagist & Composer pain in the ass. I don't like to upload thousands of unnecessary files like examples, tests etc. And there is no way how to use minified version. :-(
try “–prefer-dist”
- David Grudl
- Nette Core | 8218
Jan Tvrdík wrote:
@David Grudl I was curious so I've tried it myself. And it doesn't seem to work.
I tried it too, it didn't work.
hrach wrote:
I agree with Jan Tvrdik. From my point of view it's completely unnecessary to have https://github.com/…tte-minified repo. nette.org package (composer) repository should have do the job.
What job?
Switching to minified version should me completely managed by deployment,
Yes, it should, because I absolutely don't need Composer autoloader. But for other Composer users (without RobotLoader) it is real problem.
try “–prefer-dist”
How many libraries you know where this could help?
- Jan Tvrdík
- Nette guru | 2595
@hrach: Damn you, hrach! This was supposed to be a peaceful discussion.
@David Grudl: I've done few more experiments and found out that the Composer resolution algorithms are a bit buggy. However I think I have found a reliable way how to define dependencies.
This is a binary relation “satisfy need for” on a set
{nette/nette
, nette/nette-minified
,
nette/nette-full
}. The key to make the resolution unambiguous is
that the relation is partial
order.
nette/nette |
nette/nette-minified |
nette/nette-full |
|
nette/nette |
1 | 0 | 0 |
nette/nette-minified |
1 | 1 | 0 |
nette/nette-full |
1 | 1 | 1 |
Here is the packages.json:
{
"packages": {
"nette/nette": {
"2.0.11": {
"name": "nette/nette",
"version": "2.0.11",
"dist": {
"url": "https://github.com/nette/nette/releases/download/v2.0.11/NetteFramework-2.0.11-PHP5.3.zip",
"type": "zip"
}
}
},
"nette/nette-minified": {
"2.0.11": {
"name": "nette/nette-minified",
"version": "2.0.11",
"dist": {
"url": "https://github.com/nette/nette-minified/archive/v2.0.11.zip",
"type": "zip"
},
"replace": {
"nette/nette": "self.version"
}
}
},
"nette/nette-full": {
"2.0.11": {
"name": "nette/nette-full",
"version": "2.0.11",
"dist": {
"url": "https://github.com/nette/nette/releases/download/v2.0.11/NetteFramework-2.0.11-PHP5.3.zip",
"type": "zip"
},
"replace": {
"nette/nette": "self.version",
"nette/nette-minified": "self.version"
}
}
}
}
}
And then in composer.json you will have something like
{
"require": {
"nette/nette-minified": "2.0.*",
"nextras/application": "*"
},
"require-dev": {
"nette/nette-full": "2.0.*"
},
"repositories": [
{
"type": "composer",
"url": "https://nette.org/"
}
]
}
Note: nextras/application
is an example of package which has
dependency on nette/nette
. The need for nette/nette
is
satisfied by both nette/nette-minified
and
nette/nette-full
.
- Jan Tvrdík
- Nette guru | 2595
hrach wrote:
The discussion about minified version does not solve any other issues with other libraries, which have garbage (does not handle this by .gitattributes)
Wait for my own general-purpose composer repository and this problem will be over =)