tl;dr: Should we install packages to the default Composer location of "vendor/Vendor/Package" instead of "package/Vendor.Package", or should we have a custom Composer installer that installs to "package/Vendor.Package"?
* * *
While I have a long history with PEAR and the PEAR ecosystem, I have come to the conclusion of late that its time has passed. Its standards-body activities are being overtaken by the PHP-FIG, and its package distribution mechanism is being overtaken by Composer.
With that in mind, I'd like to use Composer as the package distribution mechanism for Aura. Specifically, this means having a composer.json file in the "system" repository, and use that to install/update packages from all vendors (including vendors not using Aura style packages).
Currently, Aura has a "package" directory where Aura-style packages go. To install a package, you copy or clone a Vendor.Package into that directory; the directory is flat, with all packages side-by-side. The system config mechanism scans that directory, looks for each instance of "Vendor.Package/config/default.php", and uses those files for default configurations. That lets the system bootstrap the configuration for each individual package.
Composer, on the other hand, installs to a default directory location called "vendor". The installed packages are in a 2-directory hierarchy organized by vendor name and package name ("vendor/Vendor/Package").
Composer allows for project-specific installers. If you look at <https://github.com/composer/installers> you will see that different frameworks can specify where to put their installed packages. Indeed, it lets them get installed to various different places in the framework structure. This means a custom Aura installer could put things in the "package" directory using the current conventions.
However, because Aura packages are designed to be self-contained, I wonder if we should change the Aura system to use the default Composer mechanism, and have packages get dropped into the default "vendor" directory (and of course get rid of the "package" directory).
That entails only one problem I can think of. We would need to modify the system config mechanism to look for config files in a different, less-efficient way. It would have to scan all "vendor/*" second-level subdirectories, then look for a "config/aura/default.php" file. Note that this means changing the library packages to use that extra "aura" subdirectory; this is because not all packages in the "vendor" directory are guaranteed to be Aura-style packages, so we need to be able to identify Aura-specific configs. (Of course, we can modify the config caching command to look in this new location when building the cached configs, so the decreased efficiency disappears at that point.)
The benefit to dropping "package/Vendor.Package" in favor of "vendor/Vendor/Package", then, is that we use the default Composer behavior to our advantage. That should make it easier on other projects who want to use Aura libraries as well, since they can assume the default Composer behavior.
tl;dr: Should we install packages to the default Composer location of "vendor/Vendor/Package" instead of "package/Vendor.Package", or should we have a custom Composer installer that installs to "package/Vendor.Package"?
* * *Hey Paul ,I prefer to go with Vendor.Package format and place in package format itself . I will try to explain why in this case below .
While I have a long history with PEAR and the PEAR ecosystem, I have come to the conclusion of late that its time has passed. Its standards-body activities are being overtaken by the PHP-FIG, and its package distribution mechanism is being overtaken by Composer.
Yes true . Pear is now sleeping and downloading a 25 MB phar is like :P .With that in mind, I'd like to use Composer as the package distribution mechanism for Aura. Specifically, this means having a composer.json file in the "system" repository, and use that to install/update packages from all vendors (including vendors not using Aura style packages).
Currently, Aura has a "package" directory where Aura-style packages go. To install a package, you copy or clone a Vendor.Package into that directory; the directory is flat, with all packages side-by-side. The system config mechanism scans that directory, looks for each instance of "Vendor.Package/config/default.php", and uses those files for default configurations. That lets the system bootstrap the configuration for each individual package.
Composer, on the other hand, installs to a default directory location called "vendor". The installed packages are in a 2-directory hierarchy organized by vendor name and package name ("vendor/Vendor/Package").
I would like to correct you here .So the default format of composer installation for Aura/Router will be likevendor/aura/router/Aura.Router/src/Aura/Router
that means we have another vendor directory . Notice the small aura/router .
Composer allows for project-specific installers. If you look at <https://github.com/composer/installers> you will see that different frameworks can specify where to put their installed packages. Indeed, it lets them get installed to various different places in the framework structure. This means a custom Aura installer could put things in the "package" directory using the current conventions.
Yes I have been lately playing it yesterday . So if anyone is interested have a look into the PRYou can have a look into the composer.json which will be used for system
However, because Aura packages are designed to be self-contained, I wonder if we should change the Aura system to use the default Composer mechanism, and have packages get dropped into the default "vendor" directory (and of course get rid of the "package" directory).
I don't have any issues if there is one more directory as I mentioned earlier :) . But if you still think its ok, I am with that also, but I don't love the change in directory structure for if we have blogged some where and we don't remember where , then its editing that place also.
That entails only one problem I can think of. We would need to modify the system config mechanism to look for config files in a different, less-efficient way. It would have to scan all "vendor/*" second-level subdirectories, then look for a "config/aura/default.php" file. Note that this means changing the library packages to use that extra "aura" subdirectory; this is because not all packages in the "vendor" directory are guaranteed to be Aura-style packages, so we need to be able to identify Aura-specific configs. (Of course, we can modify the config caching command to look in this new location when building the cached configs, so the decreased efficiency disappears at that point.)
In that case you don't need to modify config/aura , if composer installs to vendor/aura/pacakage/Aura.Package/config
{"name": "hari/contact","minimum-stability": "dev","type": "aura-package","description": "This is a sample contact page","keywords": ["aura","sample"],"time": "2012-07-30","license": "BSD","authors": [{"name": "Hari.Contact Contributors",},{"name": "Hari KT",}],"require": {"php": ">=5.4.0","composer/installers": "*"}}
$ php composer.phar update
29Updating dependencies
30 - Installing shama/aura-system-installer (dev-master)
31 Cloning d2b4b27d41042ef569a7fe6c0c9dfe54e99dc4a7
33 - Installing aura/web (1.0.0-beta3)
34 Downloading: 100%
36 - Installing aura/view (1.0.0-beta3)
37 Downloading: 100%
39 - Installing aura/sql (1.0.0-beta3)
40 Downloading: 100%
42 - Installing aura/signal (1.0.0-beta3)
43 Downloading: 100%
45 - Installing aura/router (1.0.0-beta3)
46 Downloading: 100%
48 - Installing aura/marshal (1.0.0-beta3)
49 Downloading: 100%
51 - Installing aura/http (1.0.0-beta3)
52 Downloading: 100%
54 - Installing aura/di (1.0.0-beta3)
55 Downloading: 100%
57 - Installing aura/cli (1.0.0-beta3)
58 Downloading: 100%
60 - Installing aura/autoload (1.0.0-beta3)
61 Downloading: 100%
63 - Installing aura/framework (1.0.0-beta3)
64 Downloading: 100%
66 - Installing aura/uri (1.0.0-beta3)
67 Downloading: 100%
69Writing lock file
70Generating autoload files
Regarding the composer-based install procedure, may i propose an alternative solution?
It is possible to not have Aura packages resides into the package/ dir, but instead to use the default composer's vendor/ dir.
One way to do that is to alter the Aura.Framework's Framework, Config and System classes, to store a list of Aura.* packages internally. The rest (eg the bootstrap sequence) is trivial.
I think this way is more easy to add external Aura style packages into an Aura-based project.
Don't forget (if i miss something here please correct me), an Aura style package is a package supplying it's own config/default-or-whatever-mode.php file to get included in the initial startup procedure - aka bootstraping.
Hey George Papadopoulos ,Thank you for your mail and I hope this may be your first mail to the group, so I welcome you :) .I will reply inline . Please find it .
Regarding the composer-based install procedure, may i propose an alternative solution?Sure every one can suggest alternatives :) .It is possible to not have Aura packages resides into the package/ dir, but instead to use the default composer's vendor/ dir.
Yes of-course it can. But why we kept is for aura doesn't want a vendor lock on composer . When building the initial version @Paul's idea and many of them agreed that, aura packages as a drop and work package.That means if I download via git in package folder it should work , if you download and unzip and place it in package it should work.
One way to do that is to alter the Aura.Framework's Framework, Config and System classes, to store a list of Aura.* packages internally. The rest (eg the bootstrap sequence) is trivial.
I think this way is more easy to add external Aura style packages into an Aura-based project.Its still possible with composer . For eg : when you add the name to system/composer.json and if the type of that should be aura-package .
I think the proposed solution also works with the way you describe... In my web example, you just change the paths and you 're done. This is agnostic to whatever package manager you use.
It's composer agnostic (as i said earlier). Also you may have multiple applications (eg CLI's, or Web Frontend, Admin Interface and REST api) and in each one you may use/initialize/include (you name it) only the Aura packages you need to use. This way, you can avoid the cost of 'include everything' from Aura packages in each bootstrap/initialization file. Eg, a possible web API interface doesn't need a session, although a Web Frontend does (usually :-).
What do you think?
in my humble opinion this is just another form of configuration.
This approach is more powerful (i think) in the sense that the developer has complete control on what (or not) to include. Yes, the automatic Aura.*/config/default.php inclusion is the easiest way to go but you lose control when you want to do some overrides on certain packages - maybe there is some form of doing this but i don't now of that yet :-).
Also, you can have Aura packages installed system wide :-P
Last but not least: one misconfiguration on composer.json (or an accidentally downloaded package into the packages/ dir) may can cause trouble as the inclusion of packages is a little bit 'magic' - magic in the sense of not actually seeing from the code what's going on. But please correct me if i am wrong here.
And as far as i remember some major frameworks do something like this by telling you to create the foo app bootstrap and in the list of available classes insert the 'acme' bundle and do this and that, etc
Also I am not sure how different will it become including it as you mentioned :( .
It will become different because you have to specify which packages to use.
Hi,in my humble opinion this is just another form of configuration.Yes, yes I am getting you man. I am not sure whether my message was harsh, sorry if so.
This approach is more powerful (i think) in the sense that the developer has complete control on what (or not) to include. Yes, the automatic Aura.*/config/default.php inclusion is the easiest way to go but you lose control when you want to do some overrides on certain packages - maybe there is some form of doing this but i don't now of that yet :-).
From the next release onwards when you look into the config/_packages fileyou can see the order of inclusion of the aura related package . So you want to add those your package when you need it .I agree, your idea seems good for it can be placed anywhere. I too was discussing with Paul regarding the more configuration option and at some point I felt like it will become more complex for people to understand and follow.
Also, you can have Aura packages installed system wide :-P
Last but not least: one misconfiguration on composer.json (or an accidentally downloaded package into the packages/ dir) may can cause trouble as the inclusion of packages is a little bit 'magic' - magic in the sense of not actually seeing from the code what's going on. But please correct me if i am wrong here.
I feel this is about the installation problem. For when you downloaded and trying to make use of it in development environment. I feel the developer will be able to fix it. No ?
And as far as i remember some major frameworks do something like this by telling you to create the foo app bootstrap and in the list of available classes insert the 'acme' bundle and do this and that, etc
Yes Symfony2 tells you to add your bundle in the autoloader yourself. But iirc lithium was also a plug and play.Also I am not sure how different will it become including it as you mentioned :( .
It will become different because you have to specify which packages to use.
So do you think we need another filehttps://github.com/auraphp/system/blob/develop/config/_packages.web so it will be Web related andhttps://github.com/auraphp/system/blob/develop/config/_packages.cli , so its cli related stuffs etc ?It seems horrible for me. I will wait for what @pmjones thinks about this . As he is in a conference you want to wait for few days.
<?phprequire dirname(__DIR__) . '/package/Aura.Framework/src/Aura/Framework/Bootstrap/Factory.php';$factory = new \Aura\Framework\Bootstrap\Factory;$web = $factory->newInstance('web');$web->exec();
Thank you for bringing this before the next release of Aura.Framework . He may be able to help you with this :) .
Hi George,
First, thanks for taking the time to work with Aura. I appreciate it. :-)
Now, on to your main request. I'm going to sum up, so let me know if this is in accurate. Basically, you're saying things would be better (for various reasons) if we retire the "package/" directory in favor of using the Composer-standard "vendor/" directory structure. In particular, you want control over what config files get processed, and in what order, so you can do overrides. Also, you think the "web" and "cli" portions should be able to have independent package loading, so that things only needed in one don't get configured in the other. Is that about right?
It's hard for me to answer in-line all the points you raised in the earlier discussion, so I'm going to try and give a summary response. Let me know if I missed anything you think was important, and please don't take this as a dismissal. I want to make sure your questions are fully answered, even if you don't like the answers. ;-)
* * *
Order of Config Loading
-----------------------
Part of the idea with Aura was that you'd be able to download a package to the "package/" directory, and the framework would automatically pick up its config without you needing to do anything. That worked great for two years, until we started going stable on everything, and Hari realized that doing overrides would be too hard. I stalled on it for a while but eventually understood that Hari was right. So, we added two files:
config/_mode
config/_packages
The first one makes the config mode something you can see in your project, and that doesn't depend on a particular environment variable that might be available to a web app but not to a cli one.
The second one specifies the order in which package configurations are loaded. This lets you set which package configs overrides which other ones. By default, the "installer-system" Composer installer writes to this file in the order packages are installed, so it happens automatically when you install packages. You can of course edit the file to customize the order. If you don't list a package there, then the config doesn't get loaded, so that does add one extra step when you add a package manually.
Only Load Some Configs
----------------------
As far as the "only configure some packages" issue, I don't have a good answer for you there. I'd like to avoid making people edit the bootstrapping files. The overhead from loading config files, relatively speaking, is pretty low; if that becomes the biggest single bottleneck in an application that uses a database, that's a fantastic level of performance already. Well-constructed config files shouldn't be doing much other that setting scalars, lazy-calls, and closures; those don't have the overhead of, say, including other files.
The config files can be cached, too, so that instead of reading 12 or 20 or more config files from packages, the system only reads one. (Cf. Aura\Framework\Cli\CacheConfig, which is not documented yet.)
So, while I get the idea of loading different config files for a web vs a cli app, it doesn't seem like a gigantic optimization. It'll be *some* optimization, but I don't think it'll be a huge performance gain relative to all the other things that can go on (like hitting a database).
* * *
Again, please let me know if this begins to address your concerns; I'm happy to take it up again as you see fit.
And thanks for looking at Aura in such depth!
-- pmj