<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>La Distribution Blog &#187; Tutorial</title>
	<atom:link href="http://ladistribution.net/blog/category/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://ladistribution.net/blog</link>
	<description>Infrequent news about La Distribution.</description>
	<lastBuildDate>Thu, 07 Apr 2011 13:23:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Creating Micro Web Applications with Limonade and La Distribution</title>
		<link>http://ladistribution.net/blog/2011/03/micro-web-apps-with-limonade/</link>
		<comments>http://ladistribution.net/blog/2011/03/micro-web-apps-with-limonade/#comments</comments>
		<pubDate>Thu, 31 Mar 2011 14:00:39 +0000</pubDate>
		<dc:creator>François Hodierne</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://ladistribution.net/blog/?p=677</guid>
		<description><![CDATA[In our previous blog post, we explained why La Distribution was a perfect platform to code simple web applications. Now, we&#8217;ll explain you how to start coding and distributing your first application with the Limonade framework. Given that you are a seasoned web developer, it should not be difficult. And if you&#8217;re not, hey, are [...]]]></description>
			<content:encoded><![CDATA[<p>In our <a href="http://ladistribution.net/blog/2011/03/micro-web-apps/">previous blog post</a>, we explained why La Distribution was a perfect platform to code simple web applications. Now, we&#8217;ll explain you how to start coding and distributing your first application with the <a href="http://www.limonade-php.net/">Limonade</a> framework.</p>
<p>Given that you are a seasoned web developer, it should not be difficult. And if you&#8217;re not, hey, are you sure you want to do this? :)</p>
<p><span id="more-677"></span></p>
<h3>Setup La Distribution development environment</h3>
<p>If you want to start hacking around La Distribution, we first recommend to setup a local copy from SVN and configure our command line utility. This what we&#8217;ll call from now &#8220;La Distribution development environment&#8221;.</p>
<p>First checkout La Distribution SVN repository:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">svn</span> checkout http:<span style="color: #000000; font-weight: bold;">//</span>ladistribution.net<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span> ld-dev</div></div>
<p>Alternatively, you can also use our brand new Git repository:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>github.com:ladistribution<span style="color: #000000; font-weight: bold;">/</span>ladistribution.git ld-dev</div></div>
<p>Then update permissions:</p>
<p><em>As a web developer, I believe you know that working around user permissions and web server permissions can be a bit messy. In this tutorial, for the sake of simplicity and because we&#8217;re not working on real web server, we&#8217;ll fire chmod 777. If you know better, well, do it :)</em></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">777</span> ld-dev</div></div>
<p>Now, execute the web installer, say you&#8217;re on localhost:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">http://localhost/ld-dev/installer.php</div></div>
<p>Follow on screen instructions, create the first user, eventually register a MySQL database connection, and you&#8217;re done.</p>
<p>Now, we&#8217;ll make the <strong>ladis</strong> command line utility available from the terminal.</p>
<p>To do that, you can add La Distribution /bin/ directory to your PATH. Be careful, the following code is just an example, modify it to match your system. And, it&#8217;s an absolute path.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>ld-dev<span style="color: #000000; font-weight: bold;">/</span>bin</div></div>
<p>Type <strong>ladis</strong> in the terminal to check that it works. It should output something like that:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># config: /var/www/ld-dev/dist/site.php</span><br />
<span style="color: #666666; font-style: italic;"># site: /var/www/ld-dev/</span><br />
La Distribution <span style="color: #ff0000;">'edge'</span><br />
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>c<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">2009</span>-<span style="color: #000000;">2011</span> h6e.net <span style="color: #000000; font-weight: bold;">/</span> François Hodierne <span style="color: #7a0874; font-weight: bold;">&#40;</span>http:<span style="color: #000000; font-weight: bold;">//</span>h6e.net<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
Licensed under the GPL and MIT licences.</div></div>
<h3>Create a web application using Limonade</h3>
<p>Internally, we decided to write our first Micro Web Applications using the <a href="http://www.limonade-php.net/">Limonade</a> framework. If you want to find documentation on this framework, check <a href="http://www.limonade-php.net/">their website</a>.</p>
<p>You can start from our <a href="https://github.com/ladistribution/hello-world">Hello World</a> application, it will be a good basis. You can download it from our <a href="https://github.com/ladistribution/hello-world">Github repository</a>.</p>
<p>In this tutorial, we&#8217;ll grab it directly from the command line.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>github.com:ladistribution<span style="color: #000000; font-weight: bold;">/</span>hello-world.git my-application</div></div>
<p>We&#8217;ll delete the .git folder because we just wanted to export this project, not actually track it. We&#8217;ll later version control again if needed.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> my-application<span style="color: #000000; font-weight: bold;">/</span>.git</div></div>
<p>Now, to make it your own, edit the dist/manifest.xml file and change the &#8220;id&#8221; and &#8220;name&#8221; of the application.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>my-application<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>My Application!<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; ...</div></div>
<p>If you try http://localhost/ld-dev/my-application/ immediately it will not work. You have to register the application:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ladis register my-application</div></div>
<p>As seen before, in case you encounter permission issues. Fire:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">777</span></div></div>
<h3>Build the package, share it with the world!</h3>
<p>We&#8217;ll now build the package to distribute our web application:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">cd</span> my-application<br />
ladis package build</div></div>
<p>my-application.zip is now created.</p>
<p>To make it available to other users, you should push it to a public La Distribution repository. This repository should be hosted on a public server, accessible to others.</p>
<p>It&#8217;s easy, go on any public La Distribution installation under your control (ie: not localhost). Sign in, go in <strong>Settings</strong>, then <strong>Repositories</strong>. There, create a new local repository, name it &#8220;apps&#8221; for instance.</p>
<p>Click on <strong>Manage</strong>, and upload the .zip.</p>
<p>It&#8217;s online! Now you can pass your repository <strong>Public URL</strong> to your friends so that they can install your application.</p>
<p>Of course, you can also automatize the publication from the command line. In the web panel, copy the repository &#8220;Push URL&#8221;. Then register it locally:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ladis package add-remote</div></div>
<p>Paste the <strong>Push URL</strong>, enter your credentials. And from now, pushing the package to the remote repository is that easy:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ladis package push</div></div>
<h3>Conclusion</h3>
<p>It was a bit technical but not that difficult, uh?</p>
<p>We&#8217;re now waiting for your apps! </p>
<p>Don&#8217;t hesitate to start simple apps, make it available to others and share them with a Git repository. People may be interested and help you bring your application to the next level. Speaking for me, I&#8217;m pretty sure I&#8217;ll do :)</p>
]]></content:encoded>
			<wfw:commentRss>http://ladistribution.net/blog/2011/03/micro-web-apps-with-limonade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create packages? A tutorial with Moonmoon.</title>
		<link>http://ladistribution.net/blog/2009/07/how-to-create-a-package-tutorial-with-moonmoon/</link>
		<comments>http://ladistribution.net/blog/2009/07/how-to-create-a-package-tutorial-with-moonmoon/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 08:30:35 +0000</pubDate>
		<dc:creator>François Hodierne</dc:creator>
				<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://ladistribution.net/blog/?p=19</guid>
		<description><![CDATA[Distributing a new or existing web application on La Distribution is really easy. All we have to do is to embed the application in what we call a package. As of today, La Distribution can theoretically support all PHP web applications, this mean there is tons of potential applications to package. In this tutorial we&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>Distributing a new or existing web application on La Distribution is really easy. All we have to do is to embed the application in what we call a package. As of today, La Distribution can theoretically support all PHP web applications, this mean there is tons of potential applications to package.</p>
<p><img src="http://ladistribution.net/blog/wp-content/uploads/2009/07/Image-23.png" alt="Moonmoon logo" width="241" height="59" style="float:right;padding:0 0 10px 20px" />In this tutorial we&#8217;re going to package <a href="http://moonmoon.org/">Moonmoon</a> a PHP based <a href="http://www.planetplanet.org/">PlanetPlanet</a> clone. It&#8217;s relatively simple, it&#8217;s representative of a typical web application, and better, it&#8217;s from my friend <a href="http://www.svay.com/">Maurice</a>! Frankly, I had no clue if the packaging was possible before starting writing this tutorial, so let’s cross our fingers.</p>
<p><span id="more-19"></span></p>
<p><strong>Create the simplest package.</strong></p>
<p>For the first step, we’ll focus on the basics: the deployment procedure. We’ll let the user finishes the installation through the Moonmoon install form.</p>
<p>Let’s start.</p>
<ol>
<li>
<p>Create an empty folder named &#8216;package&#8217; containing 2 sub-folders: &#8216;application&#8217; and &#8216;dist&#8217;.</p>
</li>
<li>
<p>In the dist folder, create a &#8216;manifest.xml&#8217; file with the following content.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>moonmoon<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Moonmoon<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8.12-1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>application<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
</li>
<li>
<p>In the &#8216;application&#8217; folder, copy all the files of the application you want to package. You can <a href="http://moonmoon.org/download-latest.php">download Moonmoon here</a>.</p>
<p>You should now have the following structure:</p>
<p><img class="alignnone size-full wp-image-22" src="http://ladistribution.net/blog/wp-content/uploads/2009/07/Image-15.png" alt="package arborescence" width="219" height="252" /></p>
</li>
<li>
<p>Now, zip everything in the &#8216;package&#8217; directory (but not the &#8216;package&#8217; directory itself). The &#8216;application&#8217; and &#8216;dist&#8217; directories must be at the root of the zip archive.</p>
</li>
</ol>
<p><strong>Test the package</strong></p>
<ol start="5">
<li>
<p>Log in your La Distribution install, go in the Repositories panel and create a local repository if you don&#8217;t have already one.</p>
</li>
<li>
<p>Upload the zip archive you just created.</p>
</li>
<p><img class="alignnone size-full wp-image-29" style="border: 1px solid #666;" src="http://ladistribution.net/blog/wp-content/uploads/2009/07/repo.png" alt="screenshot of the repository panel" width="300" height="344" /></p>
</li>
<li>
<p>You should now be able to install a new instance of Moonmoon in the Applications panel.</p>
</li>
</ol>
<p><strong>Doh!</strong></p>
<p>The cache directory was not created! I could have fixed that in the tutorial before but I chose to keep it real. It&#8217;s a common issue when trying to copy empty directories. One way to fix it is to create a dummy non empty file in the empty directories.</p>
<p><img class="alignnone size-full wp-image-27" src="http://ladistribution.net/blog/wp-content/uploads/2009/07/Image-17.png" alt="package arborescence with dummy file added" width="228" height="270" /></p>
<ol start="8">
<li>
<p>Now update your package version in the &#8216;manifest.xml&#8217; file.</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>moonmoon<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Moonmoon<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8.12-2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>application<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
</li>
<li>
<p>Go on your Repository panel, upload the new version.</p>
</li>
<li>
<p>Go on the Application panel, update the application, it should works now!</p>
</li>
</ol>
<p><strong>Handling advanced installation</strong></p>
<p>Because we want La Distribution to provide the same experience for all applications, we now have to skip Moonmoon install form.</p>
<p>There are generally three approaches to integrate an installation process with La Distribution:</p>
<ol>
<li> Use the web installer provided by the application, and interact with it with PHP through HTTP. Isn&#8217;t that quirky ? Yes it is, but we don&#8217;t have often the choice, and well, you just have to say yourself it&#8217;s like using a REST API&nbsp;;-)</li>
<li>Use the application libraries to perform the install. It&#8217;s currently rare but it&#8217;s the best approach, the La Distribution WordPress package has been developed this way for example.</li>
<li>Code directly in the package the installation procedure, by handling the necessary steps.</li>
</ol>
<p>For Moonmoon, the install procedure is so simple that we&#8217;ll go with the third solution. Generally, it&#8217;s always easier to do the first, while the second is the one we have to promote, particularly for complex installs.</p>
<p><strong>Introducing the installer</strong></p>
<p>Basically, an installer is a PHP class that must be added in the &#8216;dist&#8217; directory, named installer.php and extends the Ld_Installer class provided by La Distribution.</p>
<p>Now, let’s have a quick look at Moonmoon&#8217;s <a href="http://svn.sharesource.org/svn/moonmoon/trunk/install.php">install.php</a> file, line 9 to 25. It seems like we’ll just have to create two files. Let&#8217;s code that!</p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">&lt;?php</span><br />
<br />
<span style="color: #000000; font-weight: bold;">class</span> Ld_Installer_Moonmoon <span style="color: #000000; font-weight: bold;">extends</span> Ld_Installer<br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> install<span style="color: #009900;">&#40;</span><span style="color: #000088;">$preferences</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; parent<span style="color: #339933;">::</span><span style="color: #004000;">install</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$preferences</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">absolutePath</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/app/classes/Planet.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$config</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'url'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'readonly'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$preferences</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'items'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'shuffle'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'refresh'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">240</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'cache'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'nohtml'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'postmaxlength'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'cachedir'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'./cache'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000088;">$planet_config</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PlanetConfig<span style="color: #009900;">&#40;</span><span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Ld_Files<span style="color: #339933;">::</span><span style="color: #004000;">put</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">absolutePath</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/custom/config.yml'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000088;">$planet_config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toYaml</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; Ld_Files<span style="color: #339933;">::</span><span style="color: #004000;">put</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">absolutePath</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/admin/inc/pwd.inc.php'</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'&lt;?php $login=&quot;admin&quot;; $password=&quot;'</span> <span style="color: #339933;">.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/md5"><span style="color: #990000;">md5</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$preferences</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'admin_password'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'&quot;; ?&gt;'</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #000000; font-weight: bold;">?&gt;</span></div></div>
<p>The install method will be automatically called when the user will create a new instance of the application with the La Distributions user interface.</p>
<p>Where does the preferences parameter come from?</p>
<p>The preferences come from the information entered by the user in La Distribution’s install form. By default, only the &#8216;title&#8217; and &#8216;path&#8217; preferences are present in this install form but you can add other preferences in the manifest file.</p>
<p>The &#8216;admin_password&#8217; preference does not exist yet. So we&#8217;ll have to declare it in the manifest.</P></p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>moonmoon<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Moonmoon<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>8.12-3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>application<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;install<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;preference</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Admin Password&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;admin_password&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/install<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/package<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p>Don’t forget to increment the version number of the package. Packages are cached and you may become mad if you don&#8217;t do it!</p>
<p>Also, you can now delete the install.php file of the Moonmoon application as it is now useless.</p>
<p><img src="http://ladistribution.net/blog/wp-content/uploads/2009/07/Image-26.png" alt="Final package arborescence" width="238" height="254" class="alignnone size-full wp-image-66" /></p>
<p>Now, create the zip, upload it, test a new installation. Everything perfect!</p>
<p><img src="http://ladistribution.net/blog/wp-content/uploads/2009/07/moon.png" alt="Moonmoon admin interface" width="450" height="246" class="alignnone size-full wp-image-53" /></p>
<p><strong>Next?</strong></p>
<p>In a next tutorial, we&#8217;ll see how to handle advanced users integration (SSO and Roles) and UI integration (integrating the permanent bottom bar).</p>
<p>As you can see, with a minimal technical background, creating La Distribution packages is fairly easy, now what are you waiting for to create your owns?</p>
<p><em>Thanks Benoît for reviewing this tutorial!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://ladistribution.net/blog/2009/07/how-to-create-a-package-tutorial-with-moonmoon/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

