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

<channel>
	<title>Action | Jörg Drzycimski</title>
	<atom:link href="https://drzycimski.com/tag/action/feed/" rel="self" type="application/rss+xml" />
	<link>https://drzycimski.com/tag/action/</link>
	<description></description>
	<lastBuildDate>Sun, 01 Oct 2017 16:56:56 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>No-MVC Zend Framework: Rating Controller / Part VI</title>
		<link>https://drzycimski.com/programmierung/no-mvc-zend-framework-rating-controller-part-vi/</link>
					<comments>https://drzycimski.com/programmierung/no-mvc-zend-framework-rating-controller-part-vi/#respond</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Sat, 05 Feb 2011 17:49:10 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[autoloader]]></category>
		<category><![CDATA[Controller]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[View]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<guid isPermaLink="false">http://blog.drzycimski.com/?p=60</guid>

					<description><![CDATA[<p>The controller is the most important part in this ZF tutorial. This is where most of the PHP code resides. It handles all input &#8211; coming thru the file receiving the Ajax rating &#8211; as well as all output &#8211; e. g. updating the rating scores. The only liberty I took not following the ZF [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-rating-controller-part-vi/">No-MVC Zend Framework: Rating Controller / Part VI</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The controller is the most important part in this ZF tutorial. This is where most of the PHP code resides. It handles all input &#8211; coming thru the file receiving the Ajax rating &#8211; as well as all output &#8211; e. g. updating the rating scores. The only liberty I took not following the ZF way is to integrate the view scripts (a.k.a. HTML output) into classes in this controller, but you can put these classes anywhere you want if you are using ZF as an application.</p>
<p>If you are familiar with Zend&#8217;s naming conventions, and check the name of the class called in Part IV, you should be able to make an educated guess as to the name of the controller file, and the folder to store it. If not, read the ZF manual on &#8222;autoloading&#8220; 😉 The class name <code>Mylib_Rating_Controller</code> expects a file named &#8222;Controller.php&#8220; in your &#8222;library/Mylib&#8220; folder, subfolder &#8222;Rating&#8220; (you already told Zend to check &#8222;library&#8220; in your bootstrap). Create folders and file, and add the class as well as your first method:</p>
<pre class="brush:php">class Mylib_Rating_Controller
{
 public function __construct($options = null)
 {
 }

 /**
 * Get rating view
 *
 * @params int page id
 * @return string
 */
 public function getRatingView($id)
 {
 $rating = $this-&gt;getRatingById($id);
 if (!empty($rating)) {
  $average = floor($rating-&gt;rating_total / $rating-&gt;rating_votes);
 } else {
  $average = 0;
 }
 ?&gt;
 &lt;select id="&lt;?php echo $id ?&gt;"&gt;
 &lt;option value="1"&lt;?php if ($average == "1") echo ' selected="selected"';?&gt;&gt;Bad&lt;/option&gt;
 &lt;option value="2"&lt;?php if ($average == "2") echo ' selected="selected"';?&gt;&gt;Not too bad&lt;/option&gt;
 &lt;option value="3"&lt;?php if ($average == "3") echo ' selected="selected"';?&gt;&gt;Ok&lt;/option&gt;
 &lt;option value="4"&lt;?php if ($average == "4") echo ' selected="selected"';?&gt;&gt;Good&lt;/option&gt;
 &lt;option value="5"&lt;?php if ($average == "5") echo ' selected="selected"';?&gt;&gt;Terrific&lt;/option&gt;
 &lt;/select&gt;
 &lt;span id="rating_value_&lt;?php echo $id ?&gt;"&gt;&amp;nbsp;&lt;/span&gt;
 &lt;?php
 }
}
</pre>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-rating-controller-part-vi/">No-MVC Zend Framework: Rating Controller / Part VI</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://drzycimski.com/programmierung/no-mvc-zend-framework-rating-controller-part-vi/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>No-MVC Zend Framework: Bootstrapping ZF / Part III</title>
		<link>https://drzycimski.com/programmierung/no-mvc-zend-framework-bootstrapping-zf-part-iii/</link>
					<comments>https://drzycimski.com/programmierung/no-mvc-zend-framework-bootstrapping-zf-part-iii/#respond</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Wed, 05 May 2010 18:10:01 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[autoloader]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Controller]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[View]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<guid isPermaLink="false">http://blog.drzycimski.com/?p=43</guid>

					<description><![CDATA[<p>For this article, you should be familiar with at least the basics of Zend Framework, especially naming conventions. If not, check out the ZF site for beginners tutorials and/or Quickstart. If you don&#8217;t want to use ZF at all, but still need the Star Rating with PHP and Ajax, you can skip ahead to the [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-bootstrapping-zf-part-iii/">No-MVC Zend Framework: Bootstrapping ZF / Part III</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>For this article, you should be familiar with at least the basics of Zend Framework, especially naming conventions. If not, check out the ZF site for beginners tutorials and/or Quickstart.</p>
<p>If you don&#8217;t want to use ZF at all, but still need the Star Rating with PHP and Ajax, you can skip ahead to the model part.</p>
<p><strong>Bootstraping Zend Framework</strong></p>
<p>The bootstrap file is (simplified) the file where you set up your ZF environment. Bootstrapping ZF in a non-application environment is nothing more that to merely include the bootstrap file manually.</p>
<p>First step after installing ZF and the folder structure in the previous part is to create the &#8222;index.php&#8220; file in your &#8222;public&#8220; folder, and a second file in your &#8222;public/includes&#8220; folder, named &#8222;bootstrap.php&#8220;. Open &#8222;index.php&#8220; in your favorite PHP editor, and include your bootstrap:</p>
<pre class="brush:php">require_once('includes/bootstrap.php');</pre>
<p>Open your bootstrap and add the following lines:</p>
<pre class="brush:php">&lt;?php
// Define path to application directory
defined('APPLICATION_PATH')
 || define('APPLICATION_PATH', ($_SERVER['DOCUMENT_ROOT'] . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
 || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

set_include_path(implode(PATH_SEPARATOR, array(
 realpath(APPLICATION_PATH . '/../library'),
 get_include_path(),
)));

require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// Register folder library/Mylib/ for custom classes
$autoloader-&gt;registerNamespace('Mylib_');
</pre>
<p>Most lines are copied from the standard ZF bootstrap. We won&#8217;t need the APPLICATION_PATH constant for this&#8230; I just like to keep it there , in case I switch to application somewhen in the future 😉 Something to keep in mind is the APPLICATION_ENV. You need to change the &#8222;development&#8220; to &#8222;production&#8220; when you go live with your scripts &#8211; this will be explained in the configuration part.</p>
<p>The important part of the bootstrap is the Zend Autoloader, making sure all ZF components plus your own scripts are found. Nothing magical about it if you know the naming conventions. If not: the autoloader searches for a script by the parts of the class call. If you have a class named &#8222;Mylib_Rating_Controller&#8220;, Zend fetches it from &#8222;library/Mylib/Rating/Controller.php&#8220;. The class &#8222;Rating_Controller&#8220; won&#8217;t be found, because it is not defined in your namespace&#8230; unless you put <code>$autoloader-&gt;registerNamespace('Rating_')</code> in your bootstrap, that is.</p>
<p><strong>Configuration</strong></p>
<p>Next up is the configuration file, where you configure your database (and cache and about a million other things beyond the scope of this tutorial). Create a folder &#8222;configs&#8220; in your &#8222;Mylib&#8220; folder, and there a &#8222;application.ini&#8220; file. Add the following lines of code:</p>
<pre class="brush:php">[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
database.adapter = "pdo_mysql"
database.isDefaultTableAdapter = true
database.params.host = ""
database.params.username = ""
database.params.password =
database.params.dbname = ""

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
database.params.host = "localhost"
database.params.username = "root"
database.params.password =
database.params.dbname = "rating"
</pre>
<p>Each section inherits from the one before, so if you define your default DB adapter in the production section, your development section will use this default adapter as well. For more information on config files, pls. refer to the ZF manual.</p>
<p><strong>Back to bootstraping</strong></p>
<p>Now it&#8217;s time to tell ZF where to get the configuration and database options. Add the following lines to your &#8222;bootstrap.php&#8220;:</p>
<pre class="brush:php">$config = new Zend_Config_Ini($_SERVER['DOCUMENT_ROOT'] . '/../library/Mylib/configs/application.ini', APPLICATION_ENV);
$registry = Zend_Registry::getInstance();
$registry-&gt;set('config', $config);

$db = Zend_Db::factory($config-&gt;database);
Zend_Db_Table::setDefaultAdapter($db);
</pre>
<p>Now you are ready to do some coding for the actual task at hand&#8230; the rating controller 😉</p>
<p>Next up: jQuery Star Rating Rating HTML code</p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-bootstrapping-zf-part-iii/">No-MVC Zend Framework: Bootstrapping ZF / Part III</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://drzycimski.com/programmierung/no-mvc-zend-framework-bootstrapping-zf-part-iii/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Zend Framework Without MVC Part I</title>
		<link>https://drzycimski.com/programmierung/using-zend-framework-without-mvc/</link>
					<comments>https://drzycimski.com/programmierung/using-zend-framework-without-mvc/#comments</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Wed, 28 Apr 2010 10:14:45 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Action]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[Controller]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Model]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[View]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<guid isPermaLink="false">http://blog.drzycimski.com/?p=5</guid>

					<description><![CDATA[<p>I&#8217;ve been looking at a few PHP frameworks to aid the redesign of my website surfspot.de. After toying around with Cake and Symfony for a while, I finally stumbled upon Zend Framework, or ZF for short. When I started out learning ZF, it seemed to me that this was the one framework able to handle [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/using-zend-framework-without-mvc/">Zend Framework Without MVC Part I</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve been looking at a few PHP frameworks to aid the redesign of my website <a title="surfspot.de" href="http://www.surfspot.de" target="_blank" rel="noopener">surfspot.de</a>. After toying around with <a title="CakePHP" href="http://www.cakephp.org/" target="_blank" rel="noopener">Cake</a> and <a title="Symfony" href="http://www.symfony-project.org" target="_blank" rel="noopener">Symfony</a> for a while, I finally stumbled upon <a title="Zend Framework" href="http://framework.zend.com" target="_blank" rel="noopener">Zend Framework</a>, or ZF for short. When I started out learning ZF, it seemed to me that this was the one framework able to handle whatever tasks I needed, without much of a hassle like CLIs (short for Command Line Interface &#8211; just hate them), and with a very good documentation plus forum support.</p>
<p>Now, a couple of months and some 100 liters of coffee later, some parts of the structure of ZF, or even the need for the structure itself, is still a mystery to me. The separation of Model, View and Controller, IMHO, is not too bad in itself, but separating all those components into different directories, as well, only adds to the confusion. In other words, my attention span is just not long enough to figure where to change action, view and so on when those are spread across my whole server 😉</p>
<p>Anyway, somewhere along the line ZF introduced &#8220; ZF Applications&#8220;&#8230; including my worst enemy &#8211; CLIs 😉 That´s the point where I started to think that it should be possible to use ZF like a &#8222;normal&#8220; PHP library &#8211; the old &#8222;include&#8220; way &#8211; with only those components needed to perform the task. And that&#8217;s the beauty of ZF: it <em>is</em> possible. You don&#8217;t have to bother with the ZF way of doing things, you can just simply utilize all of their classes to suit your own purpose, in your own way.</p>
<p>In this little series, I will share my experience doing exactly that, hoping you&#8217;ll be able to skip some of the pitfalls I came across.</p>
<p>The post <a href="https://drzycimski.com/programmierung/using-zend-framework-without-mvc/">Zend Framework Without MVC Part I</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://drzycimski.com/programmierung/using-zend-framework-without-mvc/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
