On Thursday, February 13, 2014 4:26:19 AM UTC-5, Eric wrote:
This is more a composer question than a proper joomla framework question.
I downloaded all the framework components from their new repos under the joomla framework org into a joomla folder. I am currently loading each one as a seperate statement in the psr-4 autoloader in my projects composer.json project.
Is there a way to recursively load all components under the joomla folder rather than adding each component seperately? Its working but i"m not sure if im doing it the best way.
I know could just install the whole thing by composer but then i wouldn't be able to commit back.
It's not intuitively obvious, but yes you can.
What you do is as follows:
Add the joomla-framework to composer.json[the whole platform, not the individual components] using:
"joomla/framework" : "dev-master"
run composer install//update
Now go to vendor/joomla/framework
git remote -v
On my system:
composer git://github.com/joomla/joomla-framework.git (fetch)
composer git://github.com/joomla/joomla-framework.git (push)
origin git://github.com/joomla/joomla-framework.git (fetch)
origin git AT github.com:joomla/joomla-framework.git (push)
So you have 2 remotes, origin created by git automatically, and composer which is where composer gets it's updates from
git remote add upstream git://github.com/joomla/joomla-framework.git
git remote remove origin
In essence, we renamed "origin" as "upstream"
Grab the url for your Github fork of the framework and add it as origin, for example I would run
git remote add origin git AT github.com:garyamort/joomla-framework.git
git remote fetch origin
git remote fetch upstream
git branch -u origin/master
This will change the tracking branch for master from composer/master to origin/master
As far as composer is concerned, it doesn't matter since composer will explictly try to update the local files from the composer/master branch, it doesn't use the tracking branch feature
Now you can make changes, push them to your copy, and submit pull requests as long as you are running git from within the vendor/joomla/framework directory
For extra clarity, add the pull request branches as per:
Edit the .git/config file[in the vendor/joomla/framework directory. Find the section
url = "">
fetch = +refs/heads/*:refs/remotes/upstream/*
And add the line:
fetch = +refs/pull/*/head:refs/pull/upstream/*
[note the difference from the article which used origin instead of upstream].
Now run git fetch upstream and you will have a copy of every pull request in your local repo as well
This way, if you contribute a patch back to the framework and you need it in another project your working on, you can do the same setup above and then merge it in, for example my patch request 335 was never merged in to the code, so if I needed it I could run:
git checkout -b pull/upstream/335
git checkout master
git merge pull/upstream/335
The first command checks out the patch request branch as a new branch
the second command switches back to the local master branch
The last command merges the 335 code into the local master
I find this MUCH easier - basically any patch I am using for the framework I create a pull request for. If it is something that is still in process, I will then close the request immediately. That way the pull request branch is still there and I can use it.
If it is something I think should go into the framework, I can leave it open. If it is merged later, then when I run 'git merge pull/upstream/335 I will get the message "Already up to date". If it was not accepted yet OR was rejected it will be applied.
Finally, I find the above somewhat limited in that I have to make sure the directory path is in the vendor/joomla/framework folder[or some sub folder inside it] to push/pull to my copy of the framework repo. Make it a submodule to make it work from anywhere. To do that, go to the root of your project[I assume it is also using git] and edit the file .git/config and add a submodule block for the framework, for example mine is:
url = "" AT github.com:garyamort/joomla-framework.git
Now you can use all the git submodule commands to work with it as well:
And any submodule aware git client[such as PHPStorm] can be used to automatically push changes to the correct repository - ie changes to vendor/joomla/framework/somefile.txt will be pushed to your fork of the joomla repo, while changes to somefile.txt will be pushed to your project repo.
Personally, I find the above so convenient that instead of doing it manually I wrote some composer plugins and placed them in the .composer directory so that they automatically make all those changes for me anytime composer installs or updates the the joomla framework for a project - but I despise the command line so they require using the php libgit2 extension[git2 https://github.com/libgit2/php-git]. There are no pre-compiled versions of it, so it has to be downloaded and compiled. If you want copies of the plugin, feel free to shoot me a note and I can publish them - to date I seem to be the only one who finds it convenient enough to be worth the hassle of compiling a php extension. :-)
Framework source code: https://github.com/joomla/joomla-framework
for more information about developing with Joomla!
You received this message because you are subscribed to the Google Groups "Joomla! Framework Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to joomla-dev-framework+unsubscribe AT googlegroups.com
Visit this group at http://groups.google.com/group/joomla-dev-framework