<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2germanfull.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Sprachrohr</title>
	
	<link>http://robert-kummer.de</link>
	<description>alles, was der robbi so interessant findet</description>
	<lastBuildDate>Fri, 16 Sep 2011 09:23:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>

	
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/rok-sprachrohr" /><feedburner:info uri="rok-sprachrohr" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://superfeedr.com/hubbub" /><feedburner:feedFlare href="http://add.my.yahoo.com/content?lg=de&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://us.i1.yimg.com/us.yimg.com/i/de/my/addtomyyahoo4.gif">Subscribe with Mein Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/rok-sprachrohr" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsalloy.com/?rss=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.newsalloy.com/subrss3.gif">Subscribe with NewsAlloy</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://download.attensa.com/app/get_attensa.html?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.attensa.com/blogs/attensa/WindowsLiveWriter/BadgeredintoBadges_10C02/attensa_feed_button5.gif">Subscribe with Attensa for Outlook</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.flurry.com/pushRssFeed.do?r=fb&amp;url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.flurry.com/images/flurry_rss_logo2.gif">Subscribe with Flurry</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Frok-sprachrohr" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><item>
		<title>Tomatensalat</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/uhSmCOrhmTs/</link>
		<comments>http://robert-kummer.de/2011/06/26/tomatensalat/#comments</comments>
		<pubDate>Sun, 26 Jun 2011 12:17:28 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Toppgucker]]></category>
		<category><![CDATA[essen]]></category>
		<category><![CDATA[Grundlagenrezept]]></category>
		<category><![CDATA[Salat]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=599</guid>
		<description><![CDATA[So, heute mal wieder etwas Gesundes, nachdem es die Woche schon einen 500g Burger gab. Zutaten 5 Tomaten 2 rote Zwiebeln Sonnenblumenöl Balsamico Essig Olivenöl Ziegenkäse Kräuterlinge Pfeffer frische Kräuter Zubereitung Tomatenhälften kurz in der Pfanne mit Sonnenblumenöl anbraten. Ab &#8230; <a href="http://robert-kummer.de/2011/06/26/tomatensalat/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone colorbox-599" style="display: block; margin-right: auto; margin-left: auto;" src="/wp-content/uploads/wpid-IMG_20110626_134608.jpg" alt="Tomatensalat a la rok" width="500" height="375"/></p>
<p>So, heute mal wieder etwas Gesundes, nachdem es die Woche schon einen 500g Burger gab.</p>
<h2>Zutaten</h2>
<ol style="">
<li>5 Tomaten</li>
<li>2 rote Zwiebeln</li>
<li>Sonnenblumenöl</li>
<li>Balsamico Essig</li>
<li>Olivenöl</li>
<li>Ziegenkäse</li>
<li>Kräuterlinge</li>
<li>Pfeffer</li>
<li>frische Kräuter</li>
</ol>
<h2>Zubereitung</h2>
<p>Tomatenhälften kurz in der Pfanne mit Sonnenblumenöl anbraten. Ab 72°C sind <a title="Enterohämorrhagische Escherichia coli" href="http://de.wikipedia.org/wiki/Enteroh%C3%A4morrhagische_Escherichia_coli" target="_blank">EHEC</a> und andere Keime abgetötet. Dann aus der Pfanne nehmen und die Zwiebeln in Würfeln in die Pfanne tun, Herd ausschalten. Die Tomatenhälften klein schneiden und in die Schüssel. Wenn fertig, dann die Zwiebeln drüber und ein wenig herumrühren. Dann Ziegenkäse in kleinen Stücken drüber, Essig und Öl drüber. Kräuterlinge, Pfeffer und wenn vorhanden, frische Kräuter. Leicht umrühren und halb warm genießen.<br />
Der Käse schmeckt lecker, wenn er durch die Wärme seine Konsistenz leicht verändert.<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2009/10/14/rouladen-und-kloesse/' title='Rouladen und Klöße &#8211; Wie mache ich das?'>Rouladen und Klöße &#8211; Wie mache ich das?</a></li>
<li><a href='http://robert-kummer.de/2009/09/26/kassler-wie-mach-ich-das/' title='Kassler &#8211; Wie mach ich das?'>Kassler &#8211; Wie mach ich das?</a></li>
<li><a href='http://robert-kummer.de/2008/09/14/essen-im-dunkeln/' title='Essen im Dunkeln&#8230;'>Essen im Dunkeln&#8230;</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/9iv-Byeq4abIqPLFnxxZMqgeWKU/0/da"><img src="http://feedads.g.doubleclick.net/~a/9iv-Byeq4abIqPLFnxxZMqgeWKU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/9iv-Byeq4abIqPLFnxxZMqgeWKU/1/da"><img src="http://feedads.g.doubleclick.net/~a/9iv-Byeq4abIqPLFnxxZMqgeWKU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/uhSmCOrhmTs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2011/06/26/tomatensalat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2011/06/26/tomatensalat/</feedburner:origLink></item>
		<item>
		<title>Windows-Nutzer im Webformular vorausfüllen</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/Fn2gVYvstk8/</link>
		<comments>http://robert-kummer.de/2011/04/01/windows-nutzer-im-webformular/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 09:00:00 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Entwicklung]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/2011/04/01/windows-nutzer-im-webformular-vorausfullen/</guid>
		<description><![CDATA[Heute stand ich vor der Herausforderung einen formulargestützten Prozess zu programmieren. Dabei war die eigentliche Herausforderung den Benutzernamen des angemeldeten Nutzers unter Windows in einem Feld vorauszufüllen. Nach kurzer Recherche fand ich die Lösung mittels Java Applet. Eine andere Lösung &#8230; <a href="http://robert-kummer.de/2011/04/01/windows-nutzer-im-webformular/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft colorbox-589" title="Java Logo" src="http://www.fraline.de/faq/images/Image/0000-0999/500-599/0508_-_Java_Icon_Tasse.png" alt="" width="70" height="133" />Heute stand ich vor der Herausforderung einen formulargestützten Prozess zu programmieren. Dabei war die eigentliche Herausforderung den Benutzernamen des angemeldeten Nutzers unter Windows in einem Feld vorauszufüllen.</p>
<p>Nach kurzer Recherche fand ich die Lösung mittels Java Applet. Eine andere Lösung per ActiveX-Object hab ich gleich wieder verworfen, weil die Sicherheitsrichtlinien dabei verändert werden müssen. Das werden die Nutzer des Formulars nicht tun.</p>
<p><span id="more-589"></span>Nun also die Lösung per Java Applet.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #008000; font-style: italic; font-weight: bold;">/**
* The Username returns the system property user.name which is the session name
* of the current user logged in.
*/</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.applet.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
* @author Kummerr
*/</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Username <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Applet</span>
<span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #003399;">String</span> username <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * initialize
         */</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                username <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user.name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * returns username
         * @return String
         */</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> get<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                getAppletContext<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">showStatus</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Username is &quot;</span> <span style="color: #339933;">+</span> username<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> username<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * draws the username
         * @param Graphics g
         */</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> paint<span style="color: #009900;">&#40;</span><span style="color: #003399;">Graphics</span> g<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">paint</span><span style="color: #009900;">&#40;</span>g<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                g.<span style="color: #006633;">drawString</span><span style="color: #009900;">&#40;</span>username,<span style="color: #cc66cc;">5</span>,<span style="color: #cc66cc;">15</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Der Nutzername steht in dem Property &#8220;user.name&#8221; und läßt sich somit ganz einfach auslesen. Die Methode paint() schreibt mir den gefundenen Namen auf die Applet-Zeichenfläche (Canvas). Dies ist für Kontrollzwecke sehr positiv.</p>
<p>Die Methode get() werde ich per Javascript von der Formularseite aus ansprechen und darüber den Nutzernamen laden. Zusätzlich wird der Fensterstatus diesen Namen anzeigen.</p>
<p>Hier nun das HTML-File:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;http://www.w3.org/TR/html4/loose.dtd&quot;&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta&gt;
&lt;title&gt;Insert title here&lt;/title&gt;
&lt;script language=&quot;Javascript&quot; type=&quot;text/javascript&quot;&gt;
//&lt;![CDATA[
&lt;!--
function get()
{
        document.userform.username.value = document.usernameapp.get();
}
//--&gt;
//]]&gt;
&lt;/script&gt;
&nbsp;
&lt;/head&gt;
&lt;body&gt;
&nbsp;
&lt;applet name=&quot;usernameapp&quot; archive=&quot;username.signed.jar&quot; code=&quot;Username.class&quot; width=&quot;1&quot; height=&quot;1&quot;&gt;&lt;/applet&gt;
&nbsp;
&lt;form&gt;
&lt;input name=&quot;username&quot; /&gt;
&lt;input onclick=&quot;get();&quot; value=&quot;Get&quot; type=&quot;button&quot; /&gt;
&lt;/form&gt;</pre></div></div>

<p>So kann man die Daten übertragen. Ich hab das mit eclipse programmiert und eclipse legt automatisch eine policy-Datei an, die Rechte auf alles erlaubt. Dies ist im Live-Modus nicht zu empfehlen. Stattdessen hab ich meine Datei mit dem <code>policytool</code> angepasst.</p>
<p>Hier meine Policy-Datei:</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">/* AUTOMATICALLY GENERATED ON Tue Mar <span style="">29</span> <span style="">10</span>:<span style="">23</span>:<span style="">43</span> CEST <span style="">2011</span>*/
/* DO NOT EDIT */
&nbsp;
keystore &quot;file:/c:/Documents and Settings/XXXXXXXXX/.keystore&quot;, &quot;jks&quot;;
&nbsp;
grant signedBy &quot;mykey&quot; <span class="br0">&#123;</span>
  permission java.util.PropertyPermission &quot;user.name&quot;, &quot;read&quot;;
<span class="br0">&#125;</span>;</pre></div></div>

<p>Unter Angabe meines Keystores hab ich nur Lesezugriff auf das System-Property user.name gegeben. Mehr verwende ich auch nicht.</p>
<p>Da ohne Angabe der korrekten Policy immer eine Exception in Javascript kommt hier nochmal der Weg zu einem signierten JAR mit korrekter Policy.</p>
<ol>
<li>Keystore mit keytool (aus dem JDK) erzeugen.<br />
keytool -genkey</li>
<li>Self-Signed Zertifikat erstellen (self-signed Zertifikate sind nur 6 Monate gültig)<br />
keytool -selfcert</li>
<li>JAR aus der Klasse erzeugen<br />
jar cvf username.jar Username.class</li>
<li>Signiertes JAR erzeugen<br />
jarsigner -signedjar username.signed.jar username.jar mykey</li>
</ol>
<p>Im letzten Schritt wird bei der Signierung mein Alias aus dem Keystore angegeben. Dieser wird automatisch auf &#8220;mykey&#8221; gesetzt, wenn man bei &#8220;keytool -genkey&#8221; keine weiteren Optionen angibt. Die Policy nutzt ebenfalls diesen Alias bei &#8220;SignedBy&#8221;.</p>
<p>Im Browser muss man beim ersten Start des Applets noch die Ausführung bestätigen, dann läuft es.</p>
<p>Während der Entwicklung ändert man immer mal die Policy und den Quellcode. Hier empfiehlt es sich gerade bei Änderungen in der Policy den Cache zu löschen, da dieser nur beim ersten Laden gespeichert wird. Das hat mich ne halbe Stunde fluchen gekostet.</p>
<p>Der Quellcode zum Artikel kann heruntergeladen werden: <a href="http://robert-kummer.de/wp-content/uploads/Username-Applet.zip">Username-Applet</a><br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2006/04/04/die-kleine-ameise-mit-dem-s-auf-dem-ruecken/' title='Die kleine Ameise mit dem “S” auf dem Rücken'>Die kleine Ameise mit dem “S” auf dem Rücken</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/DD_lE1_elz0tBQJcMu2d6y2urQM/0/da"><img src="http://feedads.g.doubleclick.net/~a/DD_lE1_elz0tBQJcMu2d6y2urQM/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/DD_lE1_elz0tBQJcMu2d6y2urQM/1/da"><img src="http://feedads.g.doubleclick.net/~a/DD_lE1_elz0tBQJcMu2d6y2urQM/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/Fn2gVYvstk8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2011/04/01/windows-nutzer-im-webformular/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2011/04/01/windows-nutzer-im-webformular/</feedburner:origLink></item>
		<item>
		<title>Suchen mit Zend_Search_Lucene</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/EhHWbFWNRwE/</link>
		<comments>http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/#comments</comments>
		<pubDate>Fri, 25 Feb 2011 09:00:30 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Entwicklung]]></category>
		<category><![CDATA[lucene]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Zend_Search_Lucene]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=581</guid>
		<description><![CDATA[Eine Suche in einer MySQL-Datenbank ist arg begrenzt. Es gibt nur 2 verschiedene Suchvarianten: Pseudo-Suche mit LIKE Suche mit MATCH AGAINST Beide Möglichkeiten können mit dem richtigen Index auch zu ganz guten Ergebnissen führen. Allerdings wird es bei größeren Datenmengen &#8230; <a href="http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Eine Suche in einer MySQL-Datenbank ist arg begrenzt. Es gibt nur 2 verschiedene Suchvarianten:</p>
<ul>
<li>Pseudo-Suche mit <a href="http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like" target="_blank">LIKE</a></li>
<li>Suche mit <a href="http://dev.mysql.com/doc/refman/5.1/en/fulltext-search.html" target="_blank">MATCH AGAINST</a></li>
</ul>
<p>Beide Möglichkeiten können mit dem richtigen Index auch zu ganz guten Ergebnissen führen. Allerdings wird es bei größeren Datenmengen nicht mehr so performant. Alternativ kann man Lucene einsetzen.<br />
<span id="more-581"></span><br />
Das Zend Framework liefert eine eigene Adaption der <a href="http://lucene.apache.org" target="_blank">Apache Lucene</a> Engine in PHP: <a href="http://framework.zend.com/manual/de/zend.search.lucene.html" target="_blank">Zend_Search_Lucene</a>.</p>
<h2>Index aufbauen mit Zend_Search_Lucene</h2>
<p>Der Index bei Lucene beinhaltet alle Indexinformationen in einem binären Format. Das Format ist mit dem von Apache Lucene identisch und kann von beiden Engines genutzt und erzeugt werden.<br />
Zum <a href="http://framework.zend.com/manual/de/zend.search.lucene.index-creation.html" target="_blank">Aufbau des Indexes</a> werden Dokumente in dem Index angelegt. Jedes Dokument besteht aus Feldern. Es gibt 5 verschiedene Feldtypen:</p>
<ul>
<li>Keyword (Stichwort) Felder werden gespeichert und indiziert, was bedeutet, dass sie sowohl durchsucht als auch in Suchergebnissen angezeigt werden können. Sie werden nicht in einzelne Worte (Tokens) zerteilt. Datenbankfelder für Aufzählungen lassen sich normalerweise leicht in Keyword Felder für Zend_Search_Lucene überführen.</li>
<li>UnIndexed (unindizierte) Felder sind nicht durchsuchbar, werden aber bei Suchtreffern zurückgegeben. Datenbank Zeitstempel, Primärschlüssel, Pfade des Dateisystems und andere externe Identifikatoren sind gute Kandidaten für UnIndexed Felder.</li>
<li>Binary (binäre) Felder werden nicht in Token aufgeteilt und indiziert, aber für die Rückgabe bei Suchtreffern gespeichert. Sie können für die Speicherung aller Daten, die als binäre Zeichenkette kodiert sind, verwendet werden, wie z.B. eine Grafiksymbol.</li>
<li>Text Felder werden gespeichert, indiziert und in Token aufgeteilt. Text Felder sind geeignet für die Speicherung von Informationen wie Themen und Überschriften, die sowohl durchsuchbar sein müssen, als auch in Suchergebnissen zurückgegeben werden müssen.</li>
<li>UnStored (nicht gespeicherte) Felder werden in Token aufgeteilt und indiziert, aber nicht im Index gespeichert. Umfangreiche Texte werden am besten durch diesen Feldtyp indiziert. Gespeicherte Daten benötigen einen größeren Index auf der Festplatte, wenn du also Daten nur durchsuchbar aber nicht wieder ausgegeben haben musst, verwende ein UnStored Feld. UnStored Felder sind geeignet, wenn ein Zend_Search_Lucene Index in Kombination mit einer relationalen Datenbank verwendet wird. Du kannst große Datenfelder mit UnStored Feldern für die Suche indizieren und sie aus der relationalen Datenbank durch die Verwendung eines separaten Feldes mithilfe eines Identifikators zurückholen.</li>
</ul>
<p>(Quelle: <a href="http://framework.zend.com/manual/de/zend.search.lucene.overview.html#zend.search.lucene.index-creation.understanding-field-types" target="_blank">framework.zend.com</a>)</p>
<p>Zum Aufbau des Indexes erstelle ich mir ein PHP-Skript, welches periodisch den Index komplett aktualisiert.</p>
<p>Hier die /cronjobs/Bootstrap.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// define base path</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'BASE_PATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// define application path</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_PATH'</span><span style="color: #339933;">,</span> BASE_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/application'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// define application environment</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPLICATION_ENV'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'development'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// set include path for zend library and models</span>
<span style="color: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span>
	BASE_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/library'</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/models'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// create application, bootstrap, and run</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Application.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$application</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Application<span style="color: #009900;">&#40;</span>
	APPLICATION_ENV<span style="color: #339933;">,</span>
	APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/configs/application.ini'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$application</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">bootstrap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Hier die /cronjobs/renew-index.php:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #009933; font-style: italic;">/**
 * This script renews the lucene search index
 */</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'memory_limit'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'512M'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$fltStartTime</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Bootstrap.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$strIndex</span> <span style="color: #339933;">=</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/data/index'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//	clear all files in index folder</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">glob</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strIndex</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
try
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'opening index...'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$index</span> <span style="color: #339933;">=</span> Zend_Search_Lucene<span style="color: #339933;">::</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strIndex</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'done'</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
catch <span style="color: #009900;">&#40;</span>Zend_Search_Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'failed, index does not exist'</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'try creating...'</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$index</span> <span style="color: #339933;">=</span> Zend_Search_Lucene<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strIndex</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'done'</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$objSystems</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Default_Model_Mapper_SystemsMapper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$objSystemsRowset</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objSystems</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$objSystemsRowset</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$objSystem</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">set_time_limit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$strId</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objSystem</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">id</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// technical id of the pc</span>
	<span style="color: #000088;">$strComputerName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objSystem</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">name</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// name of pc</span>
	<span style="color: #000088;">$strFolderStructure</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objSystem</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">folder_structure</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// dirtree of system</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'indexing '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$strId</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'...'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$doc</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Search_Lucene_Document<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//	never use the field identifier id and score, they are reserved by lucene</span>
	<span style="color: #000088;">$doc</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span>Zend_Search_Lucene_Field<span style="color: #339933;">::</span><span style="color: #004000;">keyword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pcid'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strId</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$doc</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span>Zend_Search_Lucene_Field<span style="color: #339933;">::</span><span style="color: #004000;">keyword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'computername'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strComputerName</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$doc</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">addField</span><span style="color: #009900;">&#40;</span>Zend_Search_Lucene_Field<span style="color: #339933;">::</span><span style="color: #004000;">unStored</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'contents'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$strFolderStructure</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'utf-8'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'added to index'</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
	<span style="color: #000088;">$index</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">addDocument</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$doc</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'optimizing index'</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
<span style="color: #000088;">$index</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">optimize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'docs in index           : '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$index</span> <span style="color: #339933;">-&gt;</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">' undeleted docs in index: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$index</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">numDocs</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$fltTimeEnd</span> <span style="color: #339933;">=</span> <span style="color: #990000;">microtime</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'it took '</span> <span style="color: #339933;">.</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fltTimeEnd</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$fltStartTime</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'s'</span> <span style="color: #339933;">.</span> PHP_EOL<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'[DONE]'</span><span style="color: #339933;">;</span>
<span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Damit habe ich bei 25.000 PCs einen 36 MB großen Index in /application/data/index angelegt. Wichtig: beim Öffnen oder Anlegen eines Index muss man immer ein Verzeichnis angeben und keine Datei.</p>
<h2>Suchen mit Lucene</h2>
<p>Für die Nutzung der Suche habe ich folgende Such-Action in einem Controller angelegt:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * simple search form
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> searchAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$doSearch</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$doPagination</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$objSearchForm</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Machines_Form_MachineSearch<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$pageRequestHash</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//	session store</span>
	<span style="color: #000088;">$objSessionSearchResult</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Session_Namespace<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'search'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//	check requesting method:</span>
	<span style="color: #666666; font-style: italic;">//		POST is new search</span>
	<span style="color: #666666; font-style: italic;">//		GET is fresh display or paging through the results</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">isPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$strQuery</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'q'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$objSearchForm</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">populate</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'q'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$strQuery</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$pageRequestHash</span> <span style="color: #339933;">=</span> <span style="color: #990000;">base64_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">view</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">requestHash</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pageRequestHash</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$doSearch</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//	clear session store</span>
		<span style="color: #000088;">$objSessionSearchResult</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">unsetAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$pageRequestHash</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getParam</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'hash'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">!==</span> <span style="color: #000088;">$pageRequestHash</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$doPagination</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$objSearchForm</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">populate</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">'q'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">base64_decode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$pageRequestHash</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">view</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">requestHash</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$pageRequestHash</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//	clear session store</span>
			<span style="color: #000088;">$objSessionSearchResult</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">unsetAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$doSearch</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$strIndex</span> <span style="color: #339933;">=</span> APPLICATION_PATH <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/data/index'</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$objIndex</span> <span style="color: #339933;">=</span> Zend_Search_Lucene<span style="color: #339933;">::</span><span style="color: #004000;">open</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strIndex</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$objQuery</span> <span style="color: #339933;">=</span> Zend_Search_Lucene_Search_QueryParser<span style="color: #339933;">::</span><span style="color: #004000;">parse</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$strQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		try
		<span style="color: #009900;">&#123;</span>
			Application_Utilities<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'lucene simple find: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$strQuery</span><span style="color: #339933;">,</span> Zend_Log<span style="color: #339933;">::</span><span style="color: #004000;">DEBUG</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$arrQueryHits</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objIndex</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$objQuery</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Application_Utilities<span style="color: #339933;">::</span><span style="color: #990000;">log</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'lucene search finished: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$strQuery</span><span style="color: #339933;">,</span> Zend_Log<span style="color: #339933;">::</span><span style="color: #004000;">DEBUG</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$fltMaxScore</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$arrResultHits</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrQueryHits</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$objQueryHit</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$fltMaxScore</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$fltMaxScore</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objQueryHit</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">score</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #000088;">$arrResultHits</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$objQueryHit</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">lanid</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$objQueryHit</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">machineid</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
					<span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objQueryHit</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">id</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'score'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objQueryHit</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">score</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'pcid'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objQueryHit</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">pcid</span><span style="color: #339933;">,</span>
					<span style="color: #0000ff;">'computername'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objQueryHit</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">computername</span>
				<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">//	store the search query result in the session</span>
			<span style="color: #000088;">$objSessionSearchResult</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">arrResultHits</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$arrResultHits</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		catch <span style="color: #009900;">&#40;</span>Exception <span style="color: #000088;">$e</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">addErrorMessage</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$e</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$doSearch</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span>
		<span style="color: #339933;">||</span> <span style="color: #000088;">$doPagination</span> <span style="color: #339933;">===</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
		<span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$objSessionSearchResult</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">arrResultHits</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//	create a paginator with adapter</span>
		<span style="color: #000088;">$paginator</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Zend_Paginator<span style="color: #009900;">&#40;</span>
			<span style="color: #000000; font-weight: bold;">new</span> Zend_Paginator_Adapter_Array<span style="color: #009900;">&#40;</span><span style="color: #000088;">$objSessionSearchResult</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">arrResultHits</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$paginator</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">setCacheEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//	loading application settings</span>
		<span style="color: #000088;">$bootstrap</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getInvokeArg</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'bootstrap'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//	configure paginator</span>
		<span style="color: #000088;">$paginator</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">setItemCountPerPage</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> _getParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'items'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$bootstrap</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app.pagination.items_per_page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span> <span style="color: #004000;">setPageRange</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$bootstrap</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'app.pagination.page_range'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #339933;">-&gt;</span> <span style="color: #004000;">setCurrentPageNumber</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> _getParam<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'page'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//	send the objects data to the view</span>
		<span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">view</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">paginator</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$paginator</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">view</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">entries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$paginator</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">getCurrentItems</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$this</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">view</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">objForm</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$objSearchForm</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Das verwendete Formular beinhaltet lediglich ein Textfeld mit Namen &#8220;q&#8221; und einen Submit-Button.</p>
<p>Grundsätzlich fungiert die Suche als Einmal-Suche bei Absetzen des Suchbegriffes und bei der Ergebnisnavigation wird auf die Resultate aus der Session zurückgegriffen. Dies steigert die Performance, da nicht bei jedem Aufruf der Ergebnislisten eine neue Suche ausgeführt werden muss.<br />
Nachteil ist, dass ich durch &#8220;veraltete&#8221; Ergebnisse navigiere. In zeitkritischen Systemen wäre dieses Vorgehen nicht sinnvoll. In meinem Beispiel geht das aber ganz gut.<br />
Die Suche selber benötigt weniger als eine halbe Sekunde, um Ergebnisse zu einer beliebigen Anfrage herauszufinden.</p>
<p>Die Anfrage kann durch meine Nutzung den kompletten Umfang der <a href="http://framework.zend.com/manual/de/zend.search.lucene.query-language.html" target="_blank">Abfrage-API</a> von Lucene nutzen.</p>
<p>Die verwendete Konfiguration entspricht der aus meinen <a title="RAD im Zend Framework mit dem zf-Tool" href="/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/">vorherigen Beiträgen</a>.</p>
<p>Ich hoffe, ihr könnt mir mal über euren Einsatz von Lucene berichten.<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/' title='RAD im Zend Framework mit dem zf-Tool'>RAD im Zend Framework mit dem zf-Tool</a></li>
<li><a href='http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/' title='Eine Webapplikation mit Zend Framework konfigurieren'>Eine Webapplikation mit Zend Framework konfigurieren</a></li>
<li><a href='http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/' title='Eine Webapplikation mit dem Zend Framework erstellen'>Eine Webapplikation mit dem Zend Framework erstellen</a></li>
<li><a href='http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/' title='Beschreibung in einem Formular mit dem ZendFramework'>Beschreibung in einem Formular mit dem ZendFramework</a></li>
<li><a href='http://robert-kummer.de/2010/09/30/firephp-mit-dem-zendframework-nutzen/' title='FirePHP mit dem ZendFramework nutzen'>FirePHP mit dem ZendFramework nutzen</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/1LQC6tqVnXCIUZm5FmrIii5fHMw/0/da"><img src="http://feedads.g.doubleclick.net/~a/1LQC6tqVnXCIUZm5FmrIii5fHMw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/1LQC6tqVnXCIUZm5FmrIii5fHMw/1/da"><img src="http://feedads.g.doubleclick.net/~a/1LQC6tqVnXCIUZm5FmrIii5fHMw/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/EhHWbFWNRwE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/</feedburner:origLink></item>
		<item>
		<title>RAD im Zend Framework mit dem zf-Tool</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/qlqYsECf_ic/</link>
		<comments>http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 09:00:38 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Entwicklung]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=564</guid>
		<description><![CDATA[Nachdem ich in den vorherigen Beiträgen gezeigt habe, wie man eine Webapplikation erstellt und sie dann konfiguriert, will ich nun das zf Kommandozeilen-Tool näher beleuchten. Die Dokumentation dazu ist bisher sehr dünn bis nicht existent. Voraussetzungen für die Nutzung Nachdem &#8230; <a href="http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Nachdem ich in den vorherigen Beiträgen gezeigt habe, wie man eine Webapplikation <a href="/2011/02/04/webapplikation-mit-zend-framework-erstellen/">erstellt</a> und sie dann <a href="/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/">konfiguriert</a>, will ich nun das <em>zf</em> Kommandozeilen-Tool näher beleuchten. Die Dokumentation dazu ist bisher sehr dünn bis nicht existent.<br />
<span id="more-564"></span></p>
<h2>Voraussetzungen für die Nutzung</h2>
<p>Nachdem man das Zend Framework Paket heruntergeladen hat muss man es entpacken, inklusive des <em>bin</em>-Ordners. Diesen muss man dann in der Pfad-Variable PATH (unter Windows) bekannt machen, damit man überall Zugriff auf das Kommando <em>zf</em> hat. Dazu muss der library-Ordner in der Struktur wie im Paket zu finden sein.</p>
<p>Als Probe muss man in der Eingabeaufforderung folgendes Kommando eingeben:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf show version</pre></div></div>

<p>Wenn kein Fehler kommt, dann ist das zf-Tool korrekt verfügbar.</p>
<h2>A. Anlegen eines Projektes</h2>
<p>Damit wird eine komplette Projektstruktur erstellt vom Wurzelverzeichnis angefangen. Siehe meinem <a href="/2011/02/04/webapplikation-mit-zend-framework-erstellen/">ersten Beitrag</a>.<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create project <span style="color: #7a0874; font-weight: bold;">&#123;</span>ProjectName<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Konkreter Beispielaufruf</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create project zf-app</pre></div></div>

<p>Dieser Befehl erzeugt eine leere Projektverzeichnisstruktur mit diversen Grunddaten. Für die weitere Bearbeitung der Struktur mit dem <em>zf</em>-cli-Tool sollte man in das Applikations-/Projektverzeichnis wechseln.</p>
<h2>B. Anlegen eines Moduls</h2>
<p>Für die sinnvolle Teilung von anwendungsfallbezogenen Bereichen gibt es Module im Zend Framework. Ein Modul ist verzeichnisbezogen ein separates Verzeichnis unterhalb von <em>application</em> und dessen Unterordner <em>modules</em>. Es beinhaltet wiederum Unterordner für Controller, Views, Models und Formularen. Es ist quasi eine Applikation in der Applikation etwas überspitzt gesagt.</p>
<p>Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create module <span style="color: #7a0874; font-weight: bold;">&#123;</span>ModuleName<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Konkreter Beispielaufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create module Modulname</pre></div></div>

<p>Als Antwort erhält man folgendes:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Creating the following module and artifacts:
C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Modulename<span style="color: #000000; font-weight: bold;">/</span>controllers
C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Modulename<span style="color: #000000; font-weight: bold;">/</span>models
C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Modulename<span style="color: #000000; font-weight: bold;">/</span>views
C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Modulename<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span>scripts
C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Modulename<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span>helpers
C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Modulename<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span>filters
Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span></pre></td></tr></table></div>

<p>Dieser Aufruf erzeugt folgende Verzeichnisstruktur unterhalb von <em>application</em>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">modules
└───Modulename
	├───controllers
	├───models
	└───views
		├───filters
		├───helpers
		└───scripts</pre></td></tr></table></div>

<p>Um nun auch dieses neue Modul nutzen zu können muss die <em>application.ini</em> erweitert werden um folgenden Eintrag:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.frontController.moduleDirectory <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/modules&quot;</span></pre></div></div>

<p>Erst nachdem dieser Parameter gesetzt ist, wird auch das Verhalten des Zend Frameworks dahingehend geändert, dass die Applikation modulbasiert funktioniert.<br />
D.h. ein Aufruf der URL <em>zf-app.loc/Modulname</em> ohne den Konfigurationsparameter führt zu folgender Fehlermeldung:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">An error occurred
Page not found
Exception information:
&nbsp;
Message: Invalid controller specified (Modulname)
Stack trace:
&nbsp;
#0 C:\workspace\zf-app\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard-&gt;dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\workspace\zf-app\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front-&gt;dispatch()
#2 C:\workspace\zf-app\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap-&gt;run()
#3 C:\workspace\zf-app\public\index.php(26): Zend_Application-&gt;run()
#4 {main}  
&nbsp;
Request Parameters:
&nbsp;
array (
  'controller' =&gt; 'Modulname',
  'action' =&gt; 'index',
  'module' =&gt; 'default',
)</pre></td></tr></table></div>

<p>Sobald der Parameter gesetzt ist kommt folgende Fehlermeldung:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">An error occurred
Page not found
Exception information:
&nbsp;
Message: Invalid controller specified (index)
Stack trace:
&nbsp;
#0 C:\workspace\zf-app\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard-&gt;dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\workspace\zf-app\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front-&gt;dispatch()
#2 C:\workspace\zf-app\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap-&gt;run()
#3 C:\workspace\zf-app\public\index.php(26): Zend_Application-&gt;run()
#4 {main}  
&nbsp;
Request Parameters:
&nbsp;
array (
  'module' =&gt; 'Modulname',
  'controller' =&gt; 'index',
  'action' =&gt; 'index',
)</pre></td></tr></table></div>

<p>Der Unterschied ist in den &#8220;<em>Request Parameters</em>&#8221; -&gt; &#8220;<em>module</em>&#8221; und &#8220;<em>controller</em>&#8221; zu sehen.<br />
<strong>WICHTIG</strong>: Unter Windows ist ein großer Anfangsbuchstabe ein Problem bei dem Pfad zum Modul. Also unbedingt nachträglich das Verzeichnis &#8220;<em>Modulname</em>&#8221; in &#8220;<em>modulname</em>&#8221; umbenennen, andernfalls kommt statt der korrekten Seite folgende Exception:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">An error occurred
Page not found
Exception information:
&nbsp;
Message: Invalid controller specified (index)
Stack trace:
&nbsp;
#0 C:\DATA\workspace\zf-app\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard-&gt;dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 C:\DATA\workspace\zf-app\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front-&gt;dispatch()
#2 C:\DATA\workspace\zf-app\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap-&gt;run()
#3 C:\DATA\workspace\zf-app\public\index.php(26): Zend_Application-&gt;run()
#4 {main}  
&nbsp;
Request Parameters:
&nbsp;
array (
  'module' =&gt; 'machines',
  'controller' =&gt; 'index',
  'action' =&gt; 'index',
)</pre></td></tr></table></div>

<p>Seit Version <em>1.11.0</em> fügt das <em>zf</em>-Tool folgende Einstellung eigenständig in die <em>application.ini</em> hinzu:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.frontController.moduleDirectory <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/modules&quot;</span></pre></div></div>

<h2>C. Anlegen eines Controllers</h2>
<p>Zum Anlegen eines Controllers sollte man sich zuvor bewußt sein, wo dieser Controller angelegt werden soll: im <em>default</em>-Module (direkt unter <em>application/controllers</em>) oder in einem zuvor erstellten Modul.<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create controller <span style="color: #7a0874; font-weight: bold;">&#123;</span>ControllerName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>-m <span style="color: #000000; font-weight: bold;">|</span>--module=<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>ModuleName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Der Aufruf zum Erstellen im <em>default</em>-Module / entspricht auch dem Aufruf, wenn man keine modulbasierte Applikation hat:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create controller Index</pre></div></div>

<p>Dies legt einen IndexController in <em>application/controllers/IndexController.php</em> an.<br />
Der Aufruf für einen Controller innerhalb eines Moduls (das verändert auch den Klassennamen des Controllers und stellt den Modulnamen voran als Pseudo-Namensraum):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create controller Index <span style="color: #660033;">-m</span> Modulname</pre></div></div>

<p>oder</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create controller Index <span style="color: #660033;">--module</span>=Modulname</pre></div></div>

<p>Dies erstellt den <em>Modulname_IndexController</em> in <em>application/modules/Modulname/controllers/IndexController.php</em>.<br />
Folgende Antwort kommt nach dem Aufruf:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Creating a controller at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Machines<span style="color: #000000; font-weight: bold;">/</span>controllers<span style="color: #000000; font-weight: bold;">/</span>IndexController.php
Creating an index action method <span style="color: #000000; font-weight: bold;">in</span> controller Index
Creating a view script <span style="color: #000000; font-weight: bold;">for</span> the index action method at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>Machines<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>index<span style="color: #000000; font-weight: bold;">/</span>index.phtml
Creating a controller <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #c20cb9; font-weight: bold;">file</span> at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>tests<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>controllers<span style="color: #000000; font-weight: bold;">/</span>IndexControllerTest.php
Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span></pre></td></tr></table></div>

<p><strong>WICHTIG</strong>: Dies erstellt die Klassenhülle und eine leere <em>indexAction()</em>.<br />
Diese Action braucht also nicht gesondert erstellt werden. Ebenfalls wird das View-Skript <em>index.phtml</em> für die indexAction erzeugt.</p>
<h2>D. Anlegen einer Action</h2>
<p>Um einem Controller eine Action zu geben führt folgendes Kommando zum Ziel:<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create action <span style="color: #7a0874; font-weight: bold;">&#123;</span>actionName<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>-c <span style="color: #000000; font-weight: bold;">|</span>--controller-name=<span style="color: #000000; font-weight: bold;">|</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>ControllerName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>ModuleName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Konkreter Beispielaufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create action <span style="color: #c20cb9; font-weight: bold;">login</span> Index</pre></div></div>

<p>Folgende Ausgabe liefert das Kommando:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Creating an action named <span style="color: #c20cb9; font-weight: bold;">login</span> inside controller at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>controllers<span style="color: #000000; font-weight: bold;">/</span>IndexController.php
Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span>
Creating a view script <span style="color: #000000; font-weight: bold;">for</span> the <span style="color: #c20cb9; font-weight: bold;">login</span> action method at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>views<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>index<span style="color: #000000; font-weight: bold;">/</span>login.phtml
Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span></pre></td></tr></table></div>

<p>Dadurch wird die Action im Controller erzeugt und das dazugehörige View-Skript.</p>
<h2>E. Anlegen eines Views</h2>
<p>Zum separaten Anlegen eines View-Skriptes wird folgendes Kommando notwendig:<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create view <span style="color: #7a0874; font-weight: bold;">&#91;</span>-c <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>ControllerName<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>-a <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>view-script-name<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Konkreter Beispielaufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create view Index <span style="color: #7a0874; font-weight: bold;">logout</span></pre></div></div>

<p>Als Ergebnis erscheint folgendes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span></pre></div></div>

<p>Leider steht nicht, dass ein View-Skript angelegt wurde, aber das wurde es trotzdem.<br />
<strong>WICHTIG</strong>: Es wird lediglich das View-Skript selbst angelegt. Die Verwendung durch eine Action muss selbst umgesetzt werden. Bspw. kann nachträglich nochmal eine Action dazu erstellt werden mittels &#8220;<em>zf create action logout Index</em>&#8220;. Dies überschreibt allerdings das vorhandene View-Skript mit dem vordefinierten View-Skript. Das ist unschön und sollte beachtet werden.</p>
<h2>F. Anlegen eines Models</h2>
<p>Für die Implementierung der Businesslogik ist nun alles weitestgehend vorbereit. Lediglich die Akteure und Datenlieferanten [I] fehlen noch. Beginnen wir mit den Akteuren, die Businesslogik/-informationen beinhalten und einen Zugriff per Methoden ermöglichen.<br />
Ein Model sollte eine Objektinstanz widerspiegeln und deswegen mit der Einzahl benamt werden.<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create model <span style="color: #7a0874; font-weight: bold;">&#123;</span>ModelName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>-m <span style="color: #7a0874; font-weight: bold;">&#123;</span>ModuleName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Konkreter Beispielaufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create model Option <span style="color: #660033;">-m</span> system</pre></div></div>

<p>Dieser Aufruf liefert folgende Ausgabe:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Creating a model at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>Option.php
Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span></pre></td></tr></table></div>

<p>Als Ergebnis haben wir folgendes Klassenkonstrukt:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> system_Model_Option
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Dieses Model kann nun mit Methoden der Businesslogik weiter komplettiert werden. Zum Laden/Speichern von Daten aus einer Datenquelle (meist Datenbank) benötigen wir noch ein DbTable-Objekt passend zum Model. Dies wird in [I] erklärt.</p>
<h2>G. Anlegen eines Formulars</h2>
<p>Für die Generierung eines Formulars gibt es folgenden Befehl:<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create form <span style="color: #7a0874; font-weight: bold;">&#123;</span>FormName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>-m <span style="color: #7a0874; font-weight: bold;">&#123;</span>ModuleName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Konkreter Beispielaufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create form Auth</pre></div></div>

<p>Daraufhin wird folgendes Ergebnis gezeigt:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Creating a form at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>forms<span style="color: #000000; font-weight: bold;">/</span>Auth.php
Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span></pre></td></tr></table></div>

<p>Mit diesem Aufruf wird eine Formularklasse <em>Application_Form_Auth</em> unter <em>application/forms/Auth.php</em> erstellt.</p>
<h2>H. Einrichten einer Datenbankverbindung</h2>
<p>Das zf-cli-Tool bietet nur wenige Möglichkeiten, um komfortabel Konfigurationseinstellungen an der <em>application.ini</em> vorzunehmen. Eine davon ist das Aktivieren der Layoutnutzung [J], eine andere ist die Konfiguration einer Datenbankverbindung.<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf configure dbadapter <span style="color: #ff0000;">&quot;adapter={Adapter}&amp;username={Username}&amp;password={Password}&amp;dbname={DbName}&quot;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>-s <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>SectionName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Konkrete Beispielaufrufe:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf configure dbadapter <span style="color: #ff0000;">&quot;adapter=Pdo_Mysql&amp;username=root&amp;password=&amp;dbname=zfapp&quot;</span> <span style="color: #660033;">-s</span> development</pre></div></div>

<p>Liefert folgende Ausschrift:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">A db configuration <span style="color: #000000; font-weight: bold;">for</span> the development section has been written to the application config file.</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf configure dbadapter <span style="color: #ff0000;">&quot;adapter=Pdo_Mysql&amp;username=root&amp;password=&amp;dbname=transfer&quot;</span></pre></div></div>

<p>Liefert dagegen folgende Ausschrift:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">A db configuration <span style="color: #000000; font-weight: bold;">for</span> the production section has been written to the application config file.</pre></div></div>

<h2>I. Anlegen eines DbTable-Objektes als Verbindung zwischen Model und Datenbank</h2>
<p>Zum Laden, Aktualisieren und Speichern von datenbankbezogenen Werten mittels Model wird die Strukturkomponente &#8220;<em>DbTable</em>&#8221; benötigt. Alternativ kann auch ein anderen Datenlieferant (Provider) genutzt werden &#8211; meist ist aber eine Datenbank im Hintergrund.<br />
Grundlegende Aufrufstruktur:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create dbtable <span style="color: #7a0874; font-weight: bold;">&#123;</span>DbTableName<span style="color: #000000; font-weight: bold;">/</span>ModelName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>-a<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>TableNameInDatabase<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>-m <span style="color: #7a0874; font-weight: bold;">&#123;</span>ModulName<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>-f<span style="color: #000000; font-weight: bold;">|</span>--force-overwrite<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p>Damit wird ein DbTable Objekt mit dem korrekten Tabellennamen erstellt. Für eine Aktualisierung dieser Daten kann dies mit dem &#8220;<em>&#8211;force-overwrite</em>&#8221; Parameter erzwungen werden.<br />
Alternativ kann mit</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf <span style="color: #7a0874; font-weight: bold;">&#91;</span>-p<span style="color: #7a0874; font-weight: bold;">&#93;</span> create dbtable.from-database</pre></div></div>

<p>geschaut werden, welche Tabellen gefunden und welche als DbTable erstellt werden. Der Parameter &#8220;<em>-p</em>&#8221; zeigt lediglich an, was getan werden würde, tut dies aber nicht.<br />
Auf diesen Automatismus wird hier nicht weiter eingegangen.<br />
Konkreter Beispielaufruf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf create dbtable Options options <span style="color: #660033;">-m</span> system</pre></div></div>

<p>Dies liefert folgende Ausschrift:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Creating a DbTable at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>system<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>DbTable<span style="color: #000000; font-weight: bold;">/</span>Options.php
Updating project profile <span style="color: #ff0000;">'C:\workspace\zf-app/.zfproject.xml'</span></pre></td></tr></table></div>

<p>Erstellt wurde folgendes Klassenkonstrukt:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> system_Model_DbTable_Options <span style="color: #000000; font-weight: bold;">extends</span> Zend_Db_Table_Abstract
<span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_name</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'options'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Diese <em>Zend_Db_Table</em>-Kindklasse kann mit weiteren Properties entsprechend der <a href="http://framework.zend.com/manual/en/zend.db.table.relationships.html" target="_blank">Tabellendefinition</a> parametrisiert werden.<br />
Für die Verbindung zwischen Model[F] und DbTable[I] benötigt man einen Mapper [K].</p>
<h2>J. Nutzen eines Layouts</h2>
<p>Für die einheitliche Darstellung in HTML durch einen gewissen Rahmen, der wiederverwendbare Teilbereiche beinhaltet gibt es das Layout im Zend Framework. Um dieses zu verwenden gibt es folgenden Befehl:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf <span style="color: #7a0874; font-weight: bold;">enable</span> layout</pre></div></div>

<p>Das Ergebnis sieht folgendermaßen aus:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Layouts have been enabled, and a default layout created at C:\workspace\zf-app<span style="color: #000000; font-weight: bold;">/</span>application<span style="color: #000000; font-weight: bold;">/</span>layouts<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>layout.phtml
A layout entry has been added to the application config file.</pre></td></tr></table></div>

<p>Es wurde in <em>application/layouts/scripts</em> ein Layout namens <em>layout.phtml</em> angelegt. Zur Nutzung/Aktivierung des Layouts wurde folgender Konfigurationseintrag in der <em>application.ini</em> ergänzt:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.layout.layoutPath <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/layouts/scripts/&quot;</span></pre></div></div>

<p>Zur Deaktivierung gibt es übrigens:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> zf disable layout</pre></div></div>

<p>Dieser Befehl löscht allerdings keine Dateien/Konfigurationen, sondern entfernt lediglich den Hinweis in der <em>.zfproject.xml</em> Datei.<br />
<strong>WICHTIG</strong>: Eine Reaktivierung des Layouts überschreibt ohne Rückfrage die <em>layout.phtml</em>. Dies ist unschön und sollte beachtet werden.</p>
<h2>K. Erstellen eines Mappers zur Verbindung von Model und DbTable</h2>
<p>Als Voraussetzung muss ein Model[F] und ein DbTable[I] vorhanden sein. Zur Verbindung dieser beiden völlig eigenständigen Objektklassen wird der Mapper erstellt, der fallbezogen mal mit dem einen, mal mit dem anderen, mal mit beiden Objekten und/oder anderen Objekten zusammen arbeitet.<br />
Den Mapper legen wir ebenfalls in das Models-Verzeichnis. Sonst gibt es Probleme mit der Namens-zu-Klassenauflösung mit dem Auto-Loading-Prozess.<br />
Ganz konkret sieht das bspw. so aus (aus dem <a href="http://framework.zend.com/manual/en/learning.quickstart.create-model.html" target="_blank">Quickstart</a>):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Application_Model_GuestbookMapper
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000088;">$_dbTable</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setDbTable<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbTable</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbTable</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$dbTable</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000088;">$dbTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$dbTable</span> instanceof Zend_Db_Table_Abstract<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> Exception<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Invalid table data gateway provided'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_dbTable <span style="color: #339933;">=</span> <span style="color: #000088;">$dbTable</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getDbTable<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_dbTable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDbTable</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Application_Model_DbTable_Guestbook'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_dbTable<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * take the Model to retrieve data/information and use them
	 * to let the DbTable do the insert/update action
	 * @param Application_Model_Guestbook $guestbook
	 * @return void
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> save<span style="color: #009900;">&#40;</span>Application_Model_Guestbook <span style="color: #000088;">$guestbook</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$data</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'email'</span>   <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$guestbook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getEmail</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'comment'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$guestbook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getComment</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'created'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Y-m-d H:i:s'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">===</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$guestbook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDbTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">insert</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDbTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'id = ?'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * use the DbTable to load the data for given primary key and
	 * return a Model instance
	 * @param int $id
	 * @return Application_Model_Guestbook
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> find<span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDbTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$id</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span> <span style="color: #339933;">==</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$result</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">current</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$guestbook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Model_Guestbook<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$guestbook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span>
				  <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email</span><span style="color: #009900;">&#41;</span>
				  <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setComment</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</span><span style="color: #009900;">&#41;</span>
				  <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCreated</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">created</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$guestbook</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * retrieve a list of models
	 * @return array of Application_Model_Guestbook
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> fetchAll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$resultSet</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDbTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$entries</span>   <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$resultSet</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$entry</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Model_Guestbook<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$entry</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setId</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">id</span><span style="color: #009900;">&#41;</span>
				  <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setEmail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">email</span><span style="color: #009900;">&#41;</span>
				  <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setComment</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">comment</span><span style="color: #009900;">&#41;</span>
				  <span style="color: #339933;">-&gt;</span><span style="color: #004000;">setCreated</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">created</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$entries</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$entry</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$entries</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Die direkte Nutzung kann dann bspw. in einem Controller [C] erfolgen. Dies wird <a href="http://framework.zend.com/manual/en/learning.quickstart.create-model.html" target="_blank">hier</a> ebenfalls gezeigt.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> GuestbookController <span style="color: #000000; font-weight: bold;">extends</span> Zend_Controller_Action
<span style="color: #009900;">&#123;</span>
	<span style="color: #009933; font-style: italic;">/**
	 * show all guestbook entries
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> indexAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// hier den Mapper rufen, anstatt das Model,</span>
		<span style="color: #666666; font-style: italic;">// weil wir nicht eine Instanz wollen, sondern</span>
		<span style="color: #666666; font-style: italic;">// eine Liste von Instanzen</span>
		<span style="color: #000088;">$guestbook</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Model_GuestbookMapper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entries</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$guestbook</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * insert (or update) an entry
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> signAction<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$request</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$form</span>    <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Form_Guestbook<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getRequest</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isValid</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">//	the constructor has to set the values to internal properties</span>
				<span style="color: #000088;">$comment</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Model_Guestbook<span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getValues</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">//	the mapper is the communication level to the data storage: database</span>
				<span style="color: #000088;">$mapper</span>  <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Application_Model_GuestbookMapper<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">//	the mapper saves the model, we do not need any kind of DbTable</span>
				<span style="color: #666666; font-style: italic;">//	object as direct instance</span>
				<span style="color: #000088;">$mapper</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comment</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #b1b100;">return</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span>_helper<span style="color: #339933;">-&gt;</span><span style="color: #004000;">redirector</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'index'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">view</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$form</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Damit werden die Daten vom Formular in das Model übertragen und der Mapper speichert diese Daten, in dem er sie sich wieder aus dem Model holt.<br />
Sparer würden jetzt eventuell gern abkürzen und dem Mapper gleich die Daten aus dem Formular &#8211; komplett ohne Model übergeben. In dem einfachen Beispiel mag das sogar gehen, aber der wichtige Punkt <strong>Businesslogik</strong> würde dann komplett umgangen werden.<br />
In unserem Beispiel könnte im Guestbook-Model noch eine Blacklist auf die E-Mail-Adresse und eine Bewertung des Kommentars vollzogen werden, der weder im Formular selbst, noch etwas in der Datenbank zu suchen hat.<br />
Außerdem könnte eine Logikimplementierung ebenfalls einen Versand von einer Benachrichtigung auslösen. Diese sollte im Model gestartet werden und nicht im Controller/Action, damit das Model nicht nur im MVC Umfeld korrekt funktioniert, sondern vielleicht auch per API/Shell oder anderen Aufrufmöglichkeiten. Wichtig für den Versand der Benachrichtigung ist dabei nicht die Umgebung, in der erfasst wird, sondern viel mehr, dass erfasst wird.<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/' title='Eine Webapplikation mit Zend Framework konfigurieren'>Eine Webapplikation mit Zend Framework konfigurieren</a></li>
<li><a href='http://robert-kummer.de/2009/11/19/zend_xmlrpc_server-debuggen-so-gehts/' title='Zend_XmlRpc_Server debuggen – so gehts!'>Zend_XmlRpc_Server debuggen – so gehts!</a></li>
<li><a href='http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/' title='Suchen mit Zend_Search_Lucene'>Suchen mit Zend_Search_Lucene</a></li>
<li><a href='http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/' title='Eine Webapplikation mit dem Zend Framework erstellen'>Eine Webapplikation mit dem Zend Framework erstellen</a></li>
<li><a href='http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/' title='Beschreibung in einem Formular mit dem ZendFramework'>Beschreibung in einem Formular mit dem ZendFramework</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/yxATyReLgcv-6oewPFCeWa1xU3s/0/da"><img src="http://feedads.g.doubleclick.net/~a/yxATyReLgcv-6oewPFCeWa1xU3s/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/yxATyReLgcv-6oewPFCeWa1xU3s/1/da"><img src="http://feedads.g.doubleclick.net/~a/yxATyReLgcv-6oewPFCeWa1xU3s/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/qlqYsECf_ic" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/</feedburner:origLink></item>
		<item>
		<title>Eine Webapplikation mit Zend Framework konfigurieren</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/pEdcGjL_gdY/</link>
		<comments>http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/#comments</comments>
		<pubDate>Fri, 11 Feb 2011 09:00:14 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Entwicklung]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=562</guid>
		<description><![CDATA[Im letzten Teil habe ich gezeigt, wie man eine Webapplikation mit dem Zend Framework initial erstellt. Heute will ich ein paar nützliche Konfigurationseinstellungen hinzufügen, die in einer Webapplikation wichtig sind. Alle Einträge beziehen sich auf die application.ini. Korrekte Zeitzone Für &#8230; <a href="http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Im <a href="/2011/02/04/webapplikation-mit-zend-framework-erstellen/">letzten Teil</a> habe ich gezeigt, wie man eine Webapplikation mit dem Zend Framework initial erstellt. Heute will ich ein paar nützliche Konfigurationseinstellungen hinzufügen, die in einer Webapplikation wichtig sind. Alle Einträge beziehen sich auf die <em>application.ini</em>.<br />
<span id="more-562"></span></p>
<h2>Korrekte Zeitzone</h2>
<p>Für die korrekte Zeitzone der Applikation sollte folgender Eintrag im <em>[production]</em>-Teil ergänzt werden:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">phpSettings.date.timezone <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Europe/Berlin&quot;</span></pre></div></div>

<p>Mit dieser Einstellung wird intern die Funktion <a href="http://de3.php.net/manual/de/function.date-default-timezone-set.php" target="_blank">date_default_timezone_set</a> gerufen. Ich hab jetzt meine <a href="http://de3.php.net/manual/de/timezones.php" target="_blank">Zeitzone</a> gewählt. Da sollte grundsätzlich die Zeitzone aus php genutzt werden, in der die Applikation läuft.<br />
PHP-Settings können übrigens immer über die Struktur <em>phpSettings.</em> gesetz werden.</p>
<h2>Verlegen der Dateien im default-Module</h2>
<p>Das Zend Framework speichert standardmäßig im <em>application</em>-Ordner die Struktur des <em>default</em>-Modules. Um dies zu ändern geht man wie folgt vor:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.frontController.controllerDirectory <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/controllers&quot;</span></pre></div></div>

<p>ändern zu</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.frontController.controllerDirectory <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> APPLICATION_PATH </span><span style="color: #933;">&quot;/modules/default/controllers&quot;</span></pre></div></div>

<p>bzw. diesen Konfigurationseintrag löschen.<br />
Danach muss man die Ordner <em>controllers</em>, <em>models</em>, <em>views</em> unterhalb <em>application</em> nach <em>application/modules/default</em> kopieren.<br />
Damit das Default-Module sich dann auch genauso wie jedes andere Modul verhält ist folgende Konfiguration sinnvoll:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.frontController.params.prefixDefaultModule <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 1</span></pre></div></div>

<p>Dadurch verlangt das Zend Framework nun überall den Prefix &#8220;<em>Default_</em>&#8220;, wie es in anderen Modulen zwingend erforderlich ist.</p>
<h2>Aktivieren des Firebug-Loggers für das Logging im Entwicklungssystem/Firefox</h2>
<p>Voraussetzung dafür ist ein Firefox mit installiertem <a href="http://getfirebug.com/" target="_blank">Firebug AddOn</a> und <a href="http://www.firephp.org/" target="_blank">FirePHP AddOn</a>.<br />
Danach benötigt man folgende Konfiguration in der <em>application.ini</em>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;">resources.log.firebug.writerName <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Firebug&quot;</span>
resources.log.firebug.filterName <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;Priority&quot;</span>
resources.log.firebug.filterParams.priority <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> 7</span></pre></td></tr></table></div>

<p>Diese Zeilen bewirken das Aktivieren des Firebug als Writer für <em>Zend_Log</em>. Außerdem wird der Filter nach &#8220;<em>Priority</em>&#8221; aktiviert und alle Log-Meldungen mit dem maximalen Wert <em>7</em> (<em>Zend_Log::DEBUG</em>) werden dahin geschrieben. Also faktisch alle Meldungen landen in der Firebug-Konsole.<br />
Je nach Applikationsstufe sollte man hier die Priorität vermindern.<br />
Im Produktionssystem sollte gar nicht in den Firebug geschrieben werden, deshalb sollte die Definition im höchsten Modus in der <em>application.ini</em> definiert werden.</p>
<h2>Nützliche Konfigurationsparameter bei Datenbankverbindungen</h2>
<p>Verbindung als Standard-Adapter deklarieren:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.db.isDefaultTableAdapter <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span></pre></div></div>

<p>Zeichensatz der Verbindung:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">resources.db.params.charset <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> utf8</span></pre></div></div>

<p>Profiler nach Firebug schreiben lassen</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;">resources.db.params.profiler.enabled <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> true</span>
resources.db.params.profiler.class <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> Zend_Db_Profiler_Firebug</span></pre></td></tr></table></div>

<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/' title='RAD im Zend Framework mit dem zf-Tool'>RAD im Zend Framework mit dem zf-Tool</a></li>
<li><a href='http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/' title='Eine Webapplikation mit dem Zend Framework erstellen'>Eine Webapplikation mit dem Zend Framework erstellen</a></li>
<li><a href='http://robert-kummer.de/2009/11/19/zend_xmlrpc_server-debuggen-so-gehts/' title='Zend_XmlRpc_Server debuggen – so gehts!'>Zend_XmlRpc_Server debuggen – so gehts!</a></li>
<li><a href='http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/' title='Suchen mit Zend_Search_Lucene'>Suchen mit Zend_Search_Lucene</a></li>
<li><a href='http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/' title='Beschreibung in einem Formular mit dem ZendFramework'>Beschreibung in einem Formular mit dem ZendFramework</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/Aq18fUk-QjI7_32_oiBj7o5gYQE/0/da"><img src="http://feedads.g.doubleclick.net/~a/Aq18fUk-QjI7_32_oiBj7o5gYQE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Aq18fUk-QjI7_32_oiBj7o5gYQE/1/da"><img src="http://feedads.g.doubleclick.net/~a/Aq18fUk-QjI7_32_oiBj7o5gYQE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/pEdcGjL_gdY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/</feedburner:origLink></item>
		<item>
		<title>Eine Webapplikation mit dem Zend Framework erstellen</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/gPswZoT-KaI/</link>
		<comments>http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 11:42:20 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Entwicklung]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[zend framework]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=555</guid>
		<description><![CDATA[Da wir immer wieder neue ZF-Projekte für unsere Kunden erstellen, wollte ich mal meine Erfahrungen im Erstellen einer Webapplikation mit dem Zend Framework bekanntgeben. Dieser Artikel liegt schon etwas und bezieht sich deshalb auf die Version 1.8.0 des Frameworks. Aber &#8230; <a href="http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Da wir immer wieder neue ZF-Projekte für unsere Kunden erstellen, wollte ich mal meine Erfahrungen im Erstellen einer Webapplikation mit dem Zend Framework bekanntgeben.</p>
<p>Dieser Artikel liegt schon etwas und bezieht sich deshalb auf die Version 1.8.0 des Frameworks. Aber der Grundaufbau des Frameworks hat sich kaum geändert, so dass die hier geschriebenen Dinge eine gewisse Zeit ihre Richtigkeit haben werden.</p>
<p>Meine genutzten Referenzen:</p>
<ul>
<li><a href="http://framework.zend.com/manual/en/ " target="_blank">Zend Framework Manual</a></li>
<li><a href="http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf" target="_blank">Getting Started Guide</a></li>
</ul>
<p>Eingesetztes Framework:</p>
<ul>
<li><a href="http://framework.zend.com/releases/ZendFramework-1.8.0/ZendFramework-1.8.0-minimal.tar.gz" target="_blank">Zend Framework 1.8.0</a></li>
</ul>
<p>Umgebung:</p>
<ul>
<li>Windows XP</li>
<li>XAMPPlite 1.7.3 mit PHP 5.3.1, Apache 2.2.14</li>
</ul>
<p>Bei <a href="http://www.ipunkt.biz" target="_blank">ipunkt</a> arbeiten wir zwar ausschließlich auf Ubuntu-Systemen, aber der Anschaulichkeit wegen hier mal ein Tutorial auf Windows-Basis.<span id="more-555"></span></p>
<h2>1. Kommandozeilentool zf verfügbar machen</h2>
<p>Nach dem Download des Zend Framework Paketes des Paket entpacken.</p>
<p><em>zf/bin</em> und <em>zf/library/Zend</em> irgendwo hin entpacken, danach <em>zf/bin</em> in PATH-Umgebungsvariable ergänzen. Danach auf die Eingabeaufforderung wechseln.</p>
<h2>2. Neues Projekt anlegen</h2>
<p>Mein Workspace-Verzeichnis für Eclipse ist C:\workspace.</p>
<p>ZF-Projekt anlegen mit dem ZF-CLI-Tool</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">C:\workspace<span style="color: #000000; font-weight: bold;">&gt;</span> zf create project zf-app
Creating project at C:<span style="color: #000000; font-weight: bold;">/</span>workspace<span style="color: #000000; font-weight: bold;">/</span>zf-app
Note: This <span style="color: #7a0874; font-weight: bold;">command</span> created a web project, <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">more</span> information setting up your
VHOST, please see docs<span style="color: #000000; font-weight: bold;">/</span>README</pre></td></tr></table></div>

<p>In der Datei docs/README.txt steht drin, wie ich den VHOST konfigurieren muss und das kann ich eigentlich 1:1 übernehmen.</p>
<p>Mit dem zf-create-project-Befehl wurde ein komplettes Projektverzeichnis angelegt mit folgendem Inhalt:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">zf-app
│   .zfproject.xml
│
├───application
│   │   Bootstrap.php
│   │
│   ├───configs
│   │       application.ini
│   │
│   ├───controllers
│   │       ErrorController.php
│   │       IndexController.php
│   │
│   ├───models
│   └───views
│       ├───helpers
│       └───scripts
│           ├───error
│           │       error.phtml
│           │
│           └───index
│                   index.phtml
│
├───docs
│       README.txt
│
├───library
├───public
│       .htaccess
│       index.php
│
└───tests
	│   phpunit.xml
	│
	├───application
	│       bootstrap.php
	│
	└───library
		bootstrap.php</pre></td></tr></table></div>

<p>Kurze Erläuterung der einzelnen Verzeichnisse und Dateien:</p>
<ul>
<li><em>.zfproject.xml</em> beinhaltet alle Projekteinstellungen, die ich mit dem zf-cli-Tool mache</li>
<li><em>application</em> beinhaltet die für meine Applikation notwendigen Klassen und Dateien.<br />
Die <em>application.ini</em> im <em>configs</em> Verzeichnis regelt das Applikationsverhalten weitestgehend und kann vom <em>Bootstrap.php</em> ergänzt werden.<br />
Die <em>Bootstrap.php</em> kann das Standardverhalten beeinflussen und sollte grundlegende Definitionen vornehmen für Datenbankverbindungen, Cache-Verhalten, Verwaltung von Session, Registry, Locale, Translation und einigen<br />
weiteren.<br />
Auf die Verzeichnisse <em>controllers</em>, <em>models</em> und <em>views</em> wird erst im späteren Verlauf eingegangen.</li>
<li><em>docs</em> sollte man auch für die Dokumentation der eigenen Applikation nutzen. Datenbankmodelle und Serverkonfiguration oder Requirements passen hervorragend hier hin.</li>
<li><em>library</em> beinhaltet alle Bibliotheksdateien, bspw das Zend Framework sollte hier unter <em>library/Zend</em> zu finden sein.<br />
Für Nutzer eines Repositories sollte man hier des Zend Framework als External einbinden.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">svn</span> propadd <span style="color: #c20cb9; font-weight: bold;">svn</span>:external Zend http:<span style="color: #000000; font-weight: bold;">//</span>framework.zend.com<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>framework<span style="color: #000000; font-weight: bold;">/</span>standard<span style="color: #000000; font-weight: bold;">/</span>tags<span style="color: #000000; font-weight: bold;">/</span>release-1.8.0<span style="color: #000000; font-weight: bold;">/</span>library<span style="color: #000000; font-weight: bold;">/</span>Zend<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

</li>
<li><em>public</em> ist der DocumentRoot des Webservers. Dort liegt die Startdatei <em>index.php</em> und eine <em>.htaccess</em>, die das Routing für das Zend Framework übernimmt. Für eine performantere Abarbeitung des Routing empfiehlt sich das Routing komplett in die <em>httpd.conf</em> des Apache zu übertragen und gänzlich auf .htaccess Files zu verzichten. Diese werden &#8211; anders als die Konfiguration &#8211; ständig gelesen.</li>
<li><em>tests</em> ist der Ordner für TestCases mit PHPUnit und Zend_Test.</li>
</ul>
<p>Ein wichtiger Punkt für den Laufzeit-Modus der Applikation ist die Umgebungsvariable <em>APPLICATION_ENV</em>. Diese wird laut <em>docs/README.txt</em> auf &#8220;<em>development</em>&#8221; eingestellt. Das macht in einer Entwicklungsumgebung Sinn, da auf diesen Modus bezogen auch die Konfigurationsparameter der <em>application.ini</em> geladen werden.</p>
<p>In der <em>index.php</em> steht ebenfalls, dass beim Fehlen dieser Umgebungsvariable automatisch von einer Live- oder Production-Umgebung ausgegangen wird, da man davon ausgeht, dass in einer Entwicklungsumgebung gesonderte Parameter für den Apache eingestellt<br />
werden können, in einer Live-Umgebung ist dies nicht notwendig.</p>
<h2>3. Libraries kopieren</h2>
<p>Bisher haben wir das Projekt zf-app nur initial erstellen lassen und es fehlt noch das Zend Framework in der Applikation selbst. Dies wird nicht automatisch erstellt, weil man &#8211; wie oben beschrieben &#8211; diese Bibiothek durchaus per External einbinden kann. Für unser Tutorial gehen wir nun aber mal davon aus, dass wir kein SVN-Repository haben. (Wer das mal eben schnell mit SVN Repository testen möchte, dem kann ich ein <a href="http://www.demobereich.de" target="_blank">demobereich Projekt</a> empfehlen.)</p>
<p>In der <em>index.php</em> verweist ein require_once-Statement auf die Datei <em>Zend/Application.php</em>. Diese fehlt uns derzeit, deshalb würde dort folgender Fehler von PHP kommen.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">Warning: require_once(Zend/Application.php) [function.require-once]: failed to open stream: No such file or directory in C:\workspace\zf-app\public\index.php on line 18
Fatal error: require_once() [function.require]: Failed opening required 'Zend/Application.php' (include_path='C:\workspace\zf-app\library;.;\Programme\xampplite\php\PEAR') in C:\workspace\zf-app\public\index.php on line 18</pre></td></tr></table></div>

<p>Nachdem Kopieren der Zend-Library nach <em>library/Zend</em> ist dieser Fehler behoben und die <em>index.php</em> kann korrekt starten.</p>
<h2>4. VHost einrichten</h2>
<p>Wie unter <em>docs/README.txt</em> angegeben den VHost konfigurieren mit den korrekten Pfaden zur eigenen Applikation. Mit XAMPP sieht das bspw. so aus:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">80</span>
&nbsp;
<span style="color: #00007f;">ServerName</span> zf-app.loc
<span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;c:<span style="color: #000099; font-weight: bold;">\w</span>orkspace<span style="color: #000099; font-weight: bold;">\z</span>f-app<span style="color: #000099; font-weight: bold;">\p</span>ublic&quot;</span>
<span style="color: #00007f;">SetEnv</span> APPLICATION_ENV <span style="color: #7f007f;">&quot;development&quot;</span>
&nbsp;
<span style="color: #00007f;">Options</span> <span style="color: #0000ff;">All</span>
<span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
<span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
<span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
&nbsp;
<span style="color: #00007f;">ErrorLog</span> <span style="color: #7f007f;">&quot;c:<span style="color: #000099; font-weight: bold;">\P</span>rogramme<span style="color: #000099; font-weight: bold;">\x</span>ampplite<span style="color: #000099; font-weight: bold;">\a</span>pache<span style="color: #000099; font-weight: bold;">\l</span>ogs<span style="color: #000099; font-weight: bold;">\z</span>fapp-error.log&quot;</span>
<span style="color: #00007f;">CustomLog</span> <span style="color: #7f007f;">&quot;c:<span style="color: #000099; font-weight: bold;">\P</span>rogramme<span style="color: #000099; font-weight: bold;">\x</span>ampplite<span style="color: #000099; font-weight: bold;">\a</span>pache<span style="color: #000099; font-weight: bold;">\l</span>ogs<span style="color: #000099; font-weight: bold;">\z</span>fapp-access.log&quot;</span> combined</pre></td></tr></table></div>

<p>Das ist die leicht angepasste Konfiguration in der Datei c<em>:\Programme\xampplite\apache\conf\extra\httpd-vhosts.conf</em>.</p>
<p>Nun können wir den Apache starten. Wenn der Apache nicht startet, dann liegt meist ein Konfigurationsfehler vor. Konfigurationsfehler lassen sich dabei am besten in der <em>error.log</em> des Apache nachlesen.</p>
<p>Für die Nutzung einer lokalen Domain zf-app.loc muss noch ein Eintrag in der hosts Datei des Betriebssystems gemacht werden. Unter Windows ist das <em>c:\WINDOWS\system32\drivers\etc\hosts</em>, unter Linux<br />
ist das <em>/etc/hosts</em>.</p>

<div class="wp_syntax"><div class="code"><pre class="" style="font-family:monospace;">127.0.0.1	zf-app.loc</pre></div></div>

<p>Eine Konfiguration von anderen Webserver kann <a href="http://framework.zend.com/manual/en/zend.controller.quickstart.html#zend.controller.quickstart.go.rewrite" target="_blank">hier</a> nachgelesen werden.</p>
<h2>5. Webapplikation testen</h2>
<p>Jetzt im Browser die URL zf-app.loc aufrufen und man müßte folgende Seite sehen:</p>
<p><a href="http://robert-kummer.de/wp-content/uploads/zf-app_5.png"><img class="alignnone size-full wp-image-557 colorbox-555" title="Screenshot der ZF-App" src="http://robert-kummer.de/wp-content/uploads/zf-app_5.png" alt="" width="606" height="406" /></a></p>
<p>So, das war der erste Teil des Tutorials. Hiermit kann jeder eine laufende Zend Framework Webapplikation erstellen &#8211; ohne Vorkenntnisse. Tiefergehende Anpassungen werden im nächsten Tutorial erklärt.</p>
<p>Falls Ihr Ideen, Fragen und Anregungen dazu habt, dann einfach kommentieren und ich versuche all Eure Kommentare entsprechend zu beantworten.<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/' title='Eine Webapplikation mit Zend Framework konfigurieren'>Eine Webapplikation mit Zend Framework konfigurieren</a></li>
<li><a href='http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/' title='Suchen mit Zend_Search_Lucene'>Suchen mit Zend_Search_Lucene</a></li>
<li><a href='http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/' title='RAD im Zend Framework mit dem zf-Tool'>RAD im Zend Framework mit dem zf-Tool</a></li>
<li><a href='http://robert-kummer.de/2010/10/12/logfile-viewer-eclipse/' title='Logfile Viewer für Eclipse'>Logfile Viewer für Eclipse</a></li>
<li><a href='http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/' title='Beschreibung in einem Formular mit dem ZendFramework'>Beschreibung in einem Formular mit dem ZendFramework</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/MMMrW-s89y06YTs6qalfvk58fdQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/MMMrW-s89y06YTs6qalfvk58fdQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/MMMrW-s89y06YTs6qalfvk58fdQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/MMMrW-s89y06YTs6qalfvk58fdQ/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/gPswZoT-KaI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/</feedburner:origLink></item>
		<item>
		<title>Logfile Viewer für Eclipse</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/8WZvVsLXPCI/</link>
		<comments>http://robert-kummer.de/2010/10/12/logfile-viewer-eclipse/#comments</comments>
		<pubDate>Tue, 12 Oct 2010 10:00:00 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Entwicklung]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[log]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=549</guid>
		<description><![CDATA[Nachdem ich immer mal wieder Logfiles anschauen muss, wollte ich nicht mehr dauerhaft tail unter Ubuntu und Wintail unter Windows einsetzen. Da gibt es doch bestimmt etwas von Ratiopharm&#8230;oder für eclipse, hoffte ich. Gesucht, gefunden: der eclipse logviewer von Andre &#8230; <a href="http://robert-kummer.de/2010/10/12/logfile-viewer-eclipse/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Nachdem ich immer mal wieder Logfiles anschauen muss, wollte ich nicht mehr dauerhaft tail unter Ubuntu und Wintail unter Windows einsetzen. Da gibt es doch bestimmt etwas von Ratiopharm&#8230;oder für eclipse, hoffte ich.</p>
<p>Gesucht, gefunden: der <a href="http://code.google.com/a/eclipselabs.org/p/logviewer/" target="_blank">eclipse logviewer</a> von <a href="http://code.google.com/a/eclipselabs.org/u/andre.bossert/" target="_blank">Andre Bossert</a>. Update-Site: <a href="http://svn.codespot.com/a/eclipselabs.org/logviewer/trunk/de.anbos.eclipse.logviewer.update/" target="_blank">site.xml</a></p>
<p>Dieser integriert sich als View in Eclipse und lagert nun bei mir am unteren Rand von Eclipse. Total cool sind 2 Features: automatisches Tail und Highlightung nach eigenen Vorgaben. Sehr geil.</p>
<p><a href="http://robert-kummer.de/wp-content/uploads/LogViewer_view_File_0.9.8.jpg"><img class="alignleft size-full wp-image-550 colorbox-549" title="LogViewer 0.9.8" src="http://robert-kummer.de/wp-content/uploads/LogViewer_view_File_0.9.8.jpg" alt="" width="613" height="204" /></a></p>
<p>Damit kann ich nun alles im Blick behalten&#8230;auf einem Monitor eclipse mit den Logs, auf dem anderen Monitor im Browser testen mit Firebug-Konsole. So läßt es sich arbeiten.</p>
<p>Mit welchen Tools erledigt Ihr solche Aufgaben?<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/' title='Eine Webapplikation mit dem Zend Framework erstellen'>Eine Webapplikation mit dem Zend Framework erstellen</a></li>
<li><a href='http://robert-kummer.de/2009/03/23/trac-in-eclipse-nutzen/' title='Trac in Eclipse nutzen'>Trac in Eclipse nutzen</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/5M7xcTlQuGkezy_D7DpjArDAfVE/0/da"><img src="http://feedads.g.doubleclick.net/~a/5M7xcTlQuGkezy_D7DpjArDAfVE/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/5M7xcTlQuGkezy_D7DpjArDAfVE/1/da"><img src="http://feedads.g.doubleclick.net/~a/5M7xcTlQuGkezy_D7DpjArDAfVE/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/8WZvVsLXPCI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2010/10/12/logfile-viewer-eclipse/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2010/10/12/logfile-viewer-eclipse/</feedburner:origLink></item>
		<item>
		<title>Beschreibung in einem Formular mit dem ZendFramework</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/LBnOes2TTQQ/</link>
		<comments>http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 08:49:47 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Zend_Form]]></category>
		<category><![CDATA[Zend_Form_Element]]></category>
		<category><![CDATA[Zend_View_Helper]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=506</guid>
		<description><![CDATA[Kennt Ihr das Problem, dass Ihr einen Text mitten in einem Formular platzieren wollt? Ich brauche so etwas meist bei AGB-Häkchen oder Newsletter-bestellen-Häkchen. Dort behelfe ich mir derzeit mit der Beschreibung zum Formularelement, bzw. verwende ich im Template zur Ausgabe &#8230; <a href="http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Kennt Ihr das Problem, dass Ihr einen Text mitten in einem Formular platzieren wollt? Ich brauche so etwas meist bei AGB-Häkchen oder Newsletter-bestellen-Häkchen. Dort behelfe ich mir derzeit mit der Beschreibung zum Formularelement, bzw. verwende ich im Template zur Ausgabe jedes einzelne Element und schreibe den wichtigen Text einfach in HTML dazwischen. Das ist alles in allem eine nicht sehr befriedigende Lösung und gehört wohl in die Kategorie &#8220;Quick-and-dirty&#8221;.</p>
<p><span id="more-506"></span></p>
<p>&#8220;Richtiger&#8221; wäre eine Umsetzung als eigenständiges Formularelement. Ich hab es Note genannt:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @category   App
 * @package    App_Form
 * @subpackage App_Form_Element
 * @author     Robert Kummer &lt;r .kummer@ipunkt.biz&gt;
 * @see        http://www.ipunkt.biz
 * @copyright  Creative Commons Attribution 3.0 Unported License
 * @license    http://creativecommons.org/licenses/by/3.0/
 */</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * load Zend_Form_Element_Xhtml
 */</span>
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Zend/Form/Element/Xhtml.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * A note form element, which uses the shipped view helper Zend_View_Helper_FormNote
 *
 * @category   App
 * @package    App_Form
 * @subpackage App_Form_Element
 * @author     Robert Kummer &lt;/r&gt;&lt;r .kummer@ipunkt.biz&gt;
 * @see        http://www.ipunkt.biz
 * @copyright  Creative Commons Attribution 3.0 Unported License
 * @license    http://creativecommons.org/licenses/by/3.0/
 */</span>
<span style="color: #000000; font-weight: bold;">class</span> App_Form_Element_Note <span style="color: #000000; font-weight: bold;">extends</span> Zend_Form_Element_Xhtml
<span style="color: #009900;">&#123;</span>
    <span style="color: #009933; font-style: italic;">/**
     * Default view helper to use
     * @var string
     * @see Zend_View_Helper_FormNote
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$helper</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'formNote'</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * A non-existing form element is always valid
     *
     * @param mixed $value
     * @param mixed $context
     *
     * @return bool
     *
     * @see Zend_Form_Element::isValid()
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> isValid<span style="color: #009900;">&#40;</span><span style="color: #000088;">$value</span><span style="color: #339933;">,</span> <span style="color: #000088;">$context</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">&lt;/</span>r<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Ich erzeuge also ein Element, welches von Zend_Form_Element_Xhtml abgeleitet ist. Dadurch bekomme ich gleich mehrere Vorteile im Vergleich zu meiner bisherigen QnD-Lösung: Styling geht über das herkömmliche Decorator-Pattern, Hinzufügen/Löschen über die Element-Methoden innerhalb des Formulars/Subformulars, Ausgabe von HTML-Code dank der Nutzung des FormNote-ViewHelpers, komplette Nutzung der ZF-Struktur und den damit verbundenen Möglichkeiten.</p>
<p>Ich verwende standardmäßig den Zend_View_Helper_FormNote, der praktischerweise mitgeliefert wird. Dieser läßt mich kompletten HTML-Code als Value im Element übergeben und ich brauche nicht händisch das Escaping ausschalten (wie in der bisherigen QnD-Lösung).</p>
<p>So verwende ich dieses Element:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900;">&#91;</span><span style="color: #339933;">..</span><span style="color: #009900;">&#93;</span>
<span style="color: #000088;">$objNoteElement</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> App_Form_Element_Note<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'note'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$objNote</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">setValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hier kommt der Text mit &lt;em&gt;Tag&lt;/em&gt;.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$objForm</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">addElement</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$objNote</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#91;</span><span style="color: #339933;">..</span><span style="color: #009900;">&#93;</span></pre></div></div>

<p>Das erzeugt mit den Standard-Dekorierern folgende HTML-Ausgabe:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;dl class=&quot;zend_form&quot;&gt;
    &lt;!-- [..] --&gt;
&lt;dt id=&quot;note-label&quot;&gt;&lt;/dt&gt;
&lt;dd id=&quot;note-element&quot;&gt;
        Hier kommt der Text mit &lt;em&gt;Tags&lt;/em&gt;.&lt;/dd&gt;
    &lt;!-- [..] --&gt;
&lt;/dl&gt;</pre></div></div>

<p>So, das war es erstmal zu diesem Thema von mir von hier. Wer das genauso macht oder anders, der kann es ja mal kommentieren.</p>
<p>Meine verwendete ZendFramework-Version ist die <em><strong>1.10.8</strong></em>.<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/' title='Suchen mit Zend_Search_Lucene'>Suchen mit Zend_Search_Lucene</a></li>
<li><a href='http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/' title='RAD im Zend Framework mit dem zf-Tool'>RAD im Zend Framework mit dem zf-Tool</a></li>
<li><a href='http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/' title='Eine Webapplikation mit Zend Framework konfigurieren'>Eine Webapplikation mit Zend Framework konfigurieren</a></li>
<li><a href='http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/' title='Eine Webapplikation mit dem Zend Framework erstellen'>Eine Webapplikation mit dem Zend Framework erstellen</a></li>
<li><a href='http://robert-kummer.de/2010/09/30/firephp-mit-dem-zendframework-nutzen/' title='FirePHP mit dem ZendFramework nutzen'>FirePHP mit dem ZendFramework nutzen</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/o50J-7a0u2hLnIcigquSUiwjbv0/0/da"><img src="http://feedads.g.doubleclick.net/~a/o50J-7a0u2hLnIcigquSUiwjbv0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/o50J-7a0u2hLnIcigquSUiwjbv0/1/da"><img src="http://feedads.g.doubleclick.net/~a/o50J-7a0u2hLnIcigquSUiwjbv0/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/LBnOes2TTQQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/</feedburner:origLink></item>
		<item>
		<title>FirePHP mit dem ZendFramework nutzen</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/K_y_l3k-4q0/</link>
		<comments>http://robert-kummer.de/2010/09/30/firephp-mit-dem-zendframework-nutzen/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 15:24:33 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[firephp]]></category>
		<category><![CDATA[wildfire]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Zend_Wildfire]]></category>
		<category><![CDATA[Zend_Wildfire_Plugin_FirePhp]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=501</guid>
		<description><![CDATA[Das Manual des Zend Framework zum Thema Wildfire und FirePHP ist recht dürftig bis nicht existent. Wer dennoch gern etwas in der Firebug-Konsole ausgeben lassen möchte, der kann das folgendermaßen machen. Für die Ausgabe von Tabellenwerten: $message = new Zend_Wildfire_Plugin_FirePhp_TableMessage('SESSION'); &#8230; <a href="http://robert-kummer.de/2010/09/30/firephp-mit-dem-zendframework-nutzen/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://robert-kummer.de/wp-content/uploads/zf.jpg"><img class="alignright size-full wp-image-502 colorbox-501" title="Zend Framework" src="http://robert-kummer.de/wp-content/uploads/zf.jpg" alt="" width="151" height="100" /></a>Das Manual des <a href="http://framework.zend.com/" target="_blank">Zend Framework</a> zum Thema Wildfire und FirePHP ist recht dürftig bis nicht existent. Wer dennoch gern etwas in der Firebug-Konsole ausgeben lassen möchte, der kann das folgendermaßen machen.</p>
<p>Für die Ausgabe von Tabellenwerten:</p>
<pre>$message = new Zend_Wildfire_Plugin_FirePhp_TableMessage('SESSION');
$message -&gt; setHeader(array('key', 'value'));
foreach ($_SESSION as $key =&gt; $value)
{
 $message -&gt; addRow(array($key, $value));
}
// message senden
Zend_Wildfire_Plugin_FirePhp::getInstance() -&gt; send($message);</pre>
<p>Der Konstruktor bekommt dabei das Label übergeben. Dieses ist dann in der Konsole klickbar und öffnet den Inhalt der Tabelle. Mit setHeader() wird ein Array mit den Spaltenköpfen angegeben. Hier muss die Anzahl zu den Elementen in addRow() übereinstimmen &#8211; damit werden zeilenweise die darzustellenden Werte übergeben.</p>
<p>Für die Ausgabe von einfachen Meldungen:</p>
<pre>$message = new Zend_Wildfire_Plugin_FirePhp_Message('INFO', 'Hier kommt die Meldung');
$message -&gt; setLabel('Optionales Label');
// message senden
Zend_Wildfire_Plugin_FirePhp::getInstance() -&gt; send($message);
</pre>
<p>Statt dem &#8220;INFO&#8221; gibt es noch weitere Stiltypen, die bspw. ein Info-Icon, Ausrufezeichen usw. darstellen lassen. Mögliche Werte sind: LOG, INFO, WARN, ERROR, TRACE, EXCEPTION. Für weitere Details sei auf die Klasse <a href="http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Wildfire/Plugin/FirePhp.php" target="_blank">Zend/Wildfire/Plugin/FirePhp.php</a> verwiesen. Das optionale Label wird dem Meldungstext einfach vorangestellt, gefolgt von einem Doppelpunkt und Leerzeichen.</p>
<p>WICHTIG: Wenn der Wert für den Stil nicht in Großbuchstaben übergeben wird, wird keine Meldung ausgegeben.<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li><a href='http://robert-kummer.de/2011/02/25/suchen-mit-zend_search_lucene/' title='Suchen mit Zend_Search_Lucene'>Suchen mit Zend_Search_Lucene</a></li>
<li><a href='http://robert-kummer.de/2011/02/18/rapid-application-development-im-zend-framework-mit-zf/' title='RAD im Zend Framework mit dem zf-Tool'>RAD im Zend Framework mit dem zf-Tool</a></li>
<li><a href='http://robert-kummer.de/2011/02/11/webapplikation-mit-zend-framework-konfigurieren/' title='Eine Webapplikation mit Zend Framework konfigurieren'>Eine Webapplikation mit Zend Framework konfigurieren</a></li>
<li><a href='http://robert-kummer.de/2011/02/04/webapplikation-mit-zend-framework-erstellen/' title='Eine Webapplikation mit dem Zend Framework erstellen'>Eine Webapplikation mit dem Zend Framework erstellen</a></li>
<li><a href='http://robert-kummer.de/2010/10/08/beschreibung-formular-zendframework/' title='Beschreibung in einem Formular mit dem ZendFramework'>Beschreibung in einem Formular mit dem ZendFramework</a></li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/RNAfOVnVh8WCSgpO2h3JvzMcJxU/0/da"><img src="http://feedads.g.doubleclick.net/~a/RNAfOVnVh8WCSgpO2h3JvzMcJxU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/RNAfOVnVh8WCSgpO2h3JvzMcJxU/1/da"><img src="http://feedads.g.doubleclick.net/~a/RNAfOVnVh8WCSgpO2h3JvzMcJxU/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/K_y_l3k-4q0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2010/09/30/firephp-mit-dem-zendframework-nutzen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2010/09/30/firephp-mit-dem-zendframework-nutzen/</feedburner:origLink></item>
		<item>
		<title>XML Schema ohne XMLSpy erstellen</title>
		<link>http://feedproxy.google.com/~r/rok-sprachrohr/~3/YafU6_RyXFM/</link>
		<comments>http://robert-kummer.de/2010/09/24/xml-schema-ohne-xmlspy-erstellen/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 12:28:05 +0000</pubDate>
		<dc:creator>rok</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xml-schema]]></category>
		<category><![CDATA[xsd]]></category>

		<guid isPermaLink="false">http://robert-kummer.de/?p=499</guid>
		<description><![CDATA[Wer die Evaluierungsphase mit Altova XMLSpy beendet hat und dennoch ein XML Schema aus einer XML-Datei bauen muss, dem kann ich wärmstens Pagina empfehlen. Dort wird im Themenkomplex 2 sehr ausführlich auf die Schemenerstellung eingegangen. Das hat mir auch wieder &#8230; <a href="http://robert-kummer.de/2010/09/24/xml-schema-ohne-xmlspy-erstellen/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wer die Evaluierungsphase mit <a href="http://www.altova.com/de/xmlspy.html" target="_blank">Altova XMLSpy</a> beendet hat und dennoch ein XML Schema aus einer XML-Datei bauen muss, dem kann ich wärmstens <a href="http://www.pagina-online.de/xml-hintergruende/pagina-das-kompendium/themenkomplex-ii-xml/" target="_blank">Pagina</a> empfehlen.</p>
<p>Dort wird im Themenkomplex 2 sehr ausführlich auf die <a href="http://www.pagina-online.de/xml-hintergruende/pagina-das-kompendium/themenkomplex-ii-xml/xml-schema-als-dtd-alternative/" target="_blank">Schemenerstellung</a> eingegangen. Das hat mir auch wieder sehr geholfen&#8230;oder wißt ihr im Detail welche Parameter bei komplexen Typen alle notwendig sind?<br />
<h3 class='related_post_title'>Das könnte Sie auch interessieren:</h3>
<ul class='related_post'>
<li>Leider wurde kein verwandter Artikel gefunden</li>
</ul>

<p><a href="http://feedads.g.doubleclick.net/~a/lE2QJogXrUmggYpHIPDfWnOyg6o/0/da"><img src="http://feedads.g.doubleclick.net/~a/lE2QJogXrUmggYpHIPDfWnOyg6o/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/lE2QJogXrUmggYpHIPDfWnOyg6o/1/da"><img src="http://feedads.g.doubleclick.net/~a/lE2QJogXrUmggYpHIPDfWnOyg6o/1/di" border="0" ismap="true"></img></a></p><img src="http://feeds.feedburner.com/~r/rok-sprachrohr/~4/YafU6_RyXFM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://robert-kummer.de/2010/09/24/xml-schema-ohne-xmlspy-erstellen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://robert-kummer.de/2010/09/24/xml-schema-ohne-xmlspy-erstellen/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic page generated in 14.664 seconds. --><!-- Cached page generated by WP-Super-Cache on 2012-03-10 17:19:20 --><!-- Compression = gzip -->

