Atomic core and packages

It doesn’t hurt to keep in mind though, some application developers are going to need that kind of functionality, and it would be good if they could easily build it on top of the low-level architecture.

I took a bit closer look at composer and it looks really nice now.

But some problems with the current Yii structure arise, when thinking about package management.

Usually a package manager deploys the files into a single directory, in case of composer it’s ‘vendor’ by default.

Currently components, modules, commands, themes and widgets reside in different places across your application, I think with the current config options you’d not be able to customize an app in a way, that it would be able to handle modules, widgets and themes from a common parent directory.

But in general, where should Yii’s package manager place the files?

… when thinking about it, can modules be configured to run from outside ‘modules’? But nevertheless the issue still applies for themes and commands.

Personally, I’d prefer having a single “vendors” folder, mainly because with PSR-0 autoloading conventions, it simplifies autoloading. It’s quickly becoming the de-facto standard in the “high end” of the PHP community.

A detailed blog posting about composer and Symfony2

And what if we just put some information inside actual extensions? Like…

<extension>

<url value="http://blablabla" />

<type value="widget" />

<copy todir="ext.blabla" />

</extension>

Well … If yii users start to use phing we can do something like that (this is my build.xml for Myii project):

&lt;target name=&quot;extensions&quot;&gt;


    &lt;echo msg=&quot;clean extensions directory&quot; /&gt;


    &lt;exec command=&quot;rm -rf dist/app/protected/extensions/*&quot; /&gt;


    &lt;foreach list=&quot;lyiightbox, queryii, scrolltop&quot; param=&quot;module&quot; target=&quot;install-module&quot;&gt;


        &lt;property name=&quot;module-name&quot; value=&quot;&#036;{module}&quot; /&gt;


    &lt;/foreach&gt;


&lt;/target&gt;





&lt;target name=&quot;install-module&quot;&gt;

<exec command="wget https://github.com/sensorario/${module-name}/zipball/master --directory-prefix=dist/app/protected/extensions/"/>

    &lt;unzip file=&quot;dist/app/protected/extensions/master&quot; todir=&quot;dist/app/protected/extensions/&quot;&gt;


        &lt;fileset dir=&quot;.&quot;&gt;


            &lt;include name=&quot;master&quot;/&gt;


        &lt;/fileset&gt;


    &lt;/unzip&gt;


    &lt;exec command=&quot;rm -rf dist/app/protected/extensions/master&quot; /&gt;


&lt;/target&gt;

And phing automatically can download extensions from yii site and then install them inside our application.

An’installer file can also download a particular version of a packacge or extension if exists a standard way to store this informations

Now Myii project download extensions and with a config array install them. I’ve tryied with 3 my extensions:

scrolltop,

lyiightbox,

queryii,

it work!

Wtf is Phing?

Can’t it be done using regular Yaml or JSON ?

Phing is a PHP-port of Apache Ant.

jacmoe, phing is that tool that qiang use to deploy yii, code or documentation … Is a tool for php to automate some operations that now you do by hand like upload or download of file, ftp operations, git operations, …

All your application use some extensions? Every time you download them? Well…: you can schedule all task, and create a phing file (build.xml) that will do all the task in one single command. Is like yiic. But yiic stay to yii like phing stay to php.

I have a phing command the rewrite database permission. So, if i need to install my application in a database called "dbjacmoe" with user "jac" and password "moe" i do this:

$ phing database

Database name [dbtest]?

Database username [dbuser]?

Database password [dbpassword]?

I do not open any file. Phing do this for me.

That sounds really cool. Thanks Sensario and Da:Sourcerer. :)

Does Phing require shell access?

That could be a problem on some hosts.

How will it handle upgrades?

And migrations?

last time I checked, phing ran on the shell only. There might be little incentive to create a web GUI … think of the fate of the PEAR web installer.

$ pear install php-pear

$ pear channel-discover pear.phing.org

$ pear install phing/phing

Phing would be a lot cooler if it had a Pyrus (PEAR2) package.

That way, you don’t need to mess around with a PEAR repository in a central location.

<edit>

Doesn’t seem to have a Pyrus package, but it can be installed as stand-alone, so it’s great.

</edit>

Just FYI: Packagist is now a available as a github Service Hook: https://github.com/github/github-services/pull/253

I figured out that Packagist is a package manager interface for composer, right? :)

But what is a Github service hook, and why would you want to make use of it?

Well, I haven’t looked into that in detail, but as composer/packagist is a package archive dependency manager, it looks like you can automatically submit your changes made via github to your composer repo. For sure you’ll have to take care about version numbers and so on.

See also: http://groups.google.com/group/composer-dev/browse_thread/thread/9d11ac78f86aea57?hl=en

Great post about Composer/Packagist here:

http://philsturgeon.co.uk/blog/2012/03/packages-the-way-forward-for-php

Thanks for that link. Does anyone have experice with travis ci? Like the idea…

////////////////

// EDIT:

Needed to test this. :)

Just a plain skeleton app with one dead simple unit test taken from the first yii book. Took me a while to figure out how to configure dependencies, but now it works and they run unit tests for me whenever I commit something (using different php and different yii versions).

http://travis-ci.org/#!/bwoester/yiiTravisTest

As a side note, looks like symfony is already using this service:

http://travis-ci.org/#!/symfony/symfony

Using packages in Yii is just great. It will ease the work of downloading extensions or just using the main core of the framework.

I also like the idea of separating the core code from other, somehow secondary, parts like AR or Zii. Maybe one just needs to build a JSON API thus a widget like Zii would be useless there. I know that, just being there, does not affect the performance in any way but it is nicer and cleaner to have only what you need.

Thinking at where the packages would be downloaded/stored - would this be next to the framework, like official Widgets and AR classes are now or in the "extensions" folder of each Yii application? I think the answer is open to debate. While packages like AR, database drivers and widgets could sit nicely next to the framework files, packages with modules would better be in the "extensions" folder of the application.

I agree with @samdark that it would be helpful if the framework would also come in a "core only" package. A feature of the download page allowing users to get what packages they need at the download time, just like JQuery UI does, would be great.