Closed justinyost closed 9 years ago
Maybe a generation tool we could give back to the community?
For reference, here are the "Installation" docs for 3.0: http://book.cakephp.org/3.0/en/installation.html
Yeah based on the docs there is going to be a primary way to go with composer:
php composer.phar create-project --prefer-dist -s dev cakephp/app
will give you a fully built Cake 3.0 app ready and waiting (permissions and everything)
We could copy all of the things created in this create-project
command and merge in our vagrant and various other improvements (custom composer/travis/etc) and have something probably close to what we have now.
Yeah that's what I was thinking too. Essentially, all of our additional "conventions" would be in replacing the cakephp/app
part of that command line with our own loadsys/cake-skeleton
.
That still leaves the question of whether we should track the official repo or maintain our own independently. (Tracking is the way I'm leaning since it's like that app
repo will get a lot of attention initially that we can leverage "for free".)
https://getcomposer.org/doc/03-cli.md#create-project
That is interesting. To my knowledge, other package managers don't have this (npm, gems *bundler might). Forget I mentioned tooling, as this should suffice.
Just as an fyi, I did the create-project
last night in working through my composer talk. It worked like a charm, Cake3.0 project in one command and 30ish seconds.
The cakephp/app repo is still currently listed as alpha, but that doesn't surprise or bother me right now. Anyway, take a look at it to see what all they include.
For comparison, here's a (rough) list of the items I've customized in our current Skeleton that we'd want to replicate in some way for 3.0:
README.md
(standardized documentation template).gitignore
(vagrant/puppet/bin-scripts additions).editorconfig
(defaults mostly for not screwing up .yaml files).travis.yml
(Loadsys standard build settings)bootstrap.sh
(convenience wrapper for Loadsys devs to clone and prep the project after initial creation)composer.json
(bin scripts, coding standard, phpdoc, phpcs)Gruntfile.js
(test watcher and asset build tooling)package.json
(node tools)Vagrantfile
+ Lib/puphpet/
folder (vagrant VM)Config/core.php
(loading env-specific configs)Config/database.php
(loading env-specific configs)Config/phpdoc.xml
(documentation build settings)Config/phpunit.xml
(unit test settings)Console/node/
(grunt tooling)Test/Case/All*.php
(suites for running tests in batches)webroot/_pi.php
(standardized, hardened phpinfo script)webroot/robots.txt
(actually providing a sane robots file out of the box)One complication might be whether we are comfortable with our skeleton being open source. Composer might have trouble running the create-project
command on a private repo (although if your local git install already has access it might not be an issue.)
At the very least, we should experiment with composer create-project
using a new branch in our Skeleton repo here with the minimal composer details included.
composer create-project
seems like exactly the right way, since it will auto-load depencies and can run scripts post setup to get everything going correctly (move configs, set permissions, etc)
Turning this into an Enhancement: We should start a 3.0
branch and begin setting it up for testing this approach (as time allows, of course.) Using proper release tags should allow us to add this repo to Packagist for 3.0 use without having to create a new repo (since the purpose is the same but the approach in-code is just different.)
I was poking at setting up a Cake 3 app skeleton today, and the first challenge I've run into is one we've seen before. Just running composer create-project
requires that you have a minimum required PHP version install on your host system (currently 5.4.19). This includes all PHP extensions named by package dependencies. My Mac's MacPorts-installed copy of PHP didn't have the intl
package installed so the command failed.
I don't particularly want to continue to have to maintain an entire PHP ecosystem on my host system solely for the purposes of satisfying composer.json dependencies when the code I'm pulling in will never be run anywhere except inside a (bundled!) vagrant environment. Running the composer command from inside vagrant is a non-starter for two reasons:
create-project
.I don't have an elegant solution for this in mind. Ideally the composer
executable could be somehow told to ignore PHP and extensions requirements, but that doesn't seem likely to me. And I'd like to see a copy of composer
available as a "native" executable so I don't need that otherwise-pointless PHP ecosystem on my host, while I'm making a wishlist.
Either that, or we need to consider a different mechanism for pulling a fresh project skeleton onto our development machines and setting it up for use. Perhaps something along the lines of how some tools suggest you fetch and execute a script from a remote URL? (Bonus Tumblr entirely of examples of this practice.) We could bundle a plain shell script with our skeleton that did the bootstrapping for us, and include the proper invocation line in the Skeleton's README. Setting up a new project would consist of copy/pasting the invocation onto your local command line and executing (or aliasing the command locally). Of course this doesn't necessarily get around needing composer installed on your host to work around I/O speed issues though...
Thoughts?
Transcribing from Slack chat:
composer create-project
method for spawning a new project skeleton.curl http://github.com/loadsys/skeleton/bootstrap.sh | sh
. (We'd still need to run composer inside the VM to install/manage dependencies though of course.)Idea from Rick related to 2
and 4
above:
Inside the VM, symlink the /var/www/Vendor
folder to a non-shared (VM-internal-only) folder such as /var/composer/Vendor
and then run all composer
commands from inside the VM. Since composer wouldn't be installing deps to a shared folder (that would exhibit poor I/O performance) it should run quickly enough.
This wouldn't help for things like running a grunt test watcher (which again we typically do on the host for the same performance reasons), but it's a start.
In the short term, this recently-added composer command line switch may be of use: --ignore-platform-reqs
.
Making a note of a side effect. When the database.php
file makes use of the Configure class to read settings, it can no longer be manually include
d in other PHP scripts, such as bin/db-credentials
due to the Configure
class not being available. Additionally, adding App::import('Core', 'Configure');
or App::uses('Configure', 'Core');
is not sufficient either since the App class is likewise unavailable.
The only way to work around this is to use the ConfigReadShell plugin to provide command-line access to Configure arrays. The EU legacy project has hardcoded bin scripts, so they've already been directly updated to use this approach and can be used for reference.
Closing this conversation, as we've made our decision on how to move forward:
The fork of cakephp/app that existed as loadsys/app where Andrew did some invaluable initial experimentation and improvement will be retired, and migrated into loadsys/CakePHP-Skeleton's master
branch. The existing Cake 2.x compatible skeleton will live on in a mostly-archived and for-reference state in the permanent cake-2.x
branch here.
Last I read, the general idea for Cake was going to be something like this:
composer install
to load a copy of the core into the correct place.Assuming this is still the general idea, then my initial thought is to either mimic the starter repo but fully maintain our own internal copy, or fork it and manage the process of importing/merging the core team's updates as well as our own customizations.
Thoughts on this?