midgard_setup_pear
Posted on 2007-08-17 14:42:53 EEST.
It's really nice to have another part of new PHP based Midgard installer. midgard_setup_pear is quite small class ( despite the fact it's small, it's not easy to implement with completely undocumented PEAR classes ) which is responsible to install MidCOM packages from midcom pear channel.
Constructor
Very trivial:
$msp = new midgard_setup_pear();
Finally, constructor must accept midgard_config object, but at this moment it's not important.
Discover channels
$msp->set_channels();
This method update pear.php.net channel. Add pearified.com channel and discover, if it doesn't exists in your pear setup. Add pear.midcom-project.org and discover it. And, at the updates channels to fetch most recent packages info. The main goal is to update channels, so you can invoke it anywhere and as often as you need.
Install Role packages
$msp->install_midcom_roles();
Installs pearified/Role_Web, midcom/Role_Mgdschema, midcom/Role_Midgardsql' and 'midcom/Role_Midgardelement role packages.
Separate method is needed because every role package has additional config keys which have to be set. And of course this method does it for you.
If one of the package is already installed, midgard_setup_pear will inform you about this fact, and will go further a nice ellegant way:
MIDGARD SETUP: Role_Midgardelement already installed
Install packages
$msp->install_base_packages();
Installs all base and mandatory packages required to start using midcom ( including midcom itself ). This method also updates packages, so again , you may want to use it anywhere and as often as you need.
MIDGARD SETUP: net_nehmer_blog already installed
MIDGARD SETUP: Installing template_kubrick
warning: midcom/template_Kubrick requires package "midcom/fi.protie.navigation"
downloading template_Kubrick-1.0.4.tgz ...
Starting to download template_Kubrick-1.0.4.tgz (10,911 bytes)
Preferred state
You might also want to change pear's config preffered state.
$msp->set_state('beta');
Of course you should set this just after midgard_setup_pear object has been created.
I want more
So, when your script needs to install some midcom package, you just need to use __ install_midcom_package__ method.
$msp->install_midcom_package('net_nemein_reservations');
Keep in mind that this method also updates package if it's already installed and midcom channel provides newer one. You do not have to define channel here. midgard_setup_pear will do this especially for you.
There are things on heaven and earth....
Go to PEAR docs. Spent some time on reading them. If you find some method doc like this
void &someMthod($params);
do not wonder what this mehod returns. It just retuns void class instance... Yeah... void class....