<?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>PHP | Jörg Drzycimski</title>
	<atom:link href="https://drzycimski.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>https://drzycimski.com/tag/php/</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: Filter Zend_Form input with HtmlPurifier</title>
		<link>https://drzycimski.com/programmierung/no-mvc-zend-framework-filter-zend_form-input-with-htmlpurifier/</link>
					<comments>https://drzycimski.com/programmierung/no-mvc-zend-framework-filter-zend_form-input-with-htmlpurifier/#respond</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Tue, 08 Feb 2011 17:40:09 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[HTMLPurifier]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[XSS-prevention on forms]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Filter]]></category>
		<category><![CDATA[Zend_Form]]></category>
		<guid isPermaLink="false">http://www.drzycimski.com/?p=136</guid>

					<description><![CDATA[<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-filter-zend_form-input-with-htmlpurifier/">No-MVC Zend Framework: Filter Zend_Form input with HtmlPurifier</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><div class="et_pb_section et_pb_section_0 et_section_regular" >
				
				
				
				
				
				
				<div class="et_pb_row et_pb_row_0">
				<div class="et_pb_column et_pb_column_4_4 et_pb_column_0  et_pb_css_mix_blend_mode_passthrough et-last-child">
				
				
				
				
				<div class="et_pb_module et_pb_text et_pb_text_0  et_pb_text_align_left et_pb_bg_layout_light">
				
				
				
				
				<div class="et_pb_text_inner"><p>As my favorite Zend Framework guru Padraic Brady pointet out on his <a title="Padraic Brady" href="http://blog.astrumfutura.com/" target="_blank" rel="noopener">blog</a>, most forms are just about an invitation for hackers and other subversive folks to (ab)use your forms, and PHPs &#8222;addslashes&#8220; or &#8222;striptags&#8220; just don´t get the job of protecting your site done. It is one thing to assume everybody is just nice, and submits exactly what you want them to, but expect it to be different, and be prepared&#8230; just in case. That´s the point where Zend_Filter should be implemented, and even those are not to trust entirely, as tests have shown.</p>
<p>To prevent cross site scripting, better known as XSS, Padraic recommends <a title="HtmlPurifier" href="http://htmlpurifier.org/" target="_blank" rel="noopener">HtmlPurifier</a> as preferred method of filtering user input on web forms, so I´d suggest we comply 😉 Get the newest version of HtmlPurifier, and unzip the contents into a subdirectory &#8222;HTMLPurifier&#8220; of you &#8222;library/JD/&#8220; folder (or whatever your personal folder is called). Make sure you have the upper case characters correct, iX OS is not as forgiving as Windows 😉 In the following code, I used upper case HTMLP* for original files, and HtmlP* for those I wrote, so don´t get mixed up here.</p>
<p>Next, create &#8222;HtmlPurifier.php&#8220; in a subfolder &#8222;Filter&#8220; (according to &#8222;addPrefixPath in your form controller settings). I chose to not make &#8222;Filter&#8220; a subfolder of &#8222;Forms&#8220; (unlike &#8222;Decorator&#8220; and &#8222;Validator&#8220;), because I might use the filter to clean output from databases or other sources, instead of only input from forms. In this file, find the code:</p>
<pre class="brush:php">class JD_Filter_HtmlPurifier implements Zend_Filter_Interface
{
 /**
 * The HTMLPurifier instance
 *
 * @var HTMLPurifier
 */
 protected $_htmlPurifier;

 /**
 * Constructor
 *
 * @param mixed $config
 * @return void
 */
 public function __construct($config = null)
 {
   require_once 'JD/HMTLPurifier/HTMLPurifier.auto.php';
   $this-&gt;_htmlPurifier = new HTMLPurifier($config);
 }

 /**
 * Defined by Zend_Filter_Interface
 *
 * Returns the string $value, purified by HTMLPurifier
 *
 * @param string $value
 * @return string
 */
 public function filter($value)
 {
   return $this-&gt;_htmlPurifier-&gt;purify($value);
 }
}
</pre>
<p>The $config will hold those tags allowed for this specific instance (pls refer to HtmlPurifier´s docs for details). Those values will come from the general config file, so edit your &#8222;/configs/application.ini&#8220;, and add the following lines to your &#8222;production&#8220; section:</p>
<pre class="brush:php">/*Editor and Purifier*/
allowedHTML.Restrictive = "sup"
allowedHTML.Minimal = "p,em,strong"
allowedHTML.Standard = "p,em,strong,ul,ol,li"
allowedHTML.Extended = "p,em,strong,ul,ol,li,sub,sup,a[href]"
</pre>
<p>If you ever implement a WYSIWYG editor like CKEditor, you can re-use this part of your &#8222;application.ini&#8220; to set the toolbars allowed for the editor. As for the allowed tags, please adjust as you see fit.  The &#8222;restrictive&#8220; is just the tag I wouldn´t expect in any user input, so I will use that one to filter names and mail addresses.</p>
<p>If you´re getting impatient about how to use this, add the following line to a text element of your Zend_Form:</p>
<pre class="brush:php">$form_element["comment_text"]-&gt;addFilter('HtmlPurifier', array(array('HTML.Allowed' =&gt; $this-&gt;registry-&gt;config-&gt;allowedHTML-&gt;Minimal)));
</pre>
<p>For now, this only filters the comment text element (which is a textarea, BTW). The smart thing to do would be, to check if the input is XSS, and return an error in form of &#8222;the finger&#8220; :D. Got to figure out how to do it sometime.</p>
<p>Anyway, you can <a href="https://drzycimski.com/wp-content/uploads/2011/02/Zend_Forms.zip">download &#8222;Zend_Forms.zip&#8220;</a>, containing the directory structure and files from this series, including the &#8222;bootstrap.php&#8220; in the &#8222;public&#8220; folder. Please note you need ZF in your &#8222;library/Zend/&#8220; and HtmlPurifier in your &#8222;JD/HTMLPurifier&#8220; folders!</p>
<p>The next article will show how to put all this stuff into use &#8211; a comment form. I´m already figuring out a smart way to do it without reloading the page, but still using the filters, so it looks like it´s going to need some AJAX.</p></div>
			</div>
			</div>
				
				
				
				
			</div>
				
				
			</div><div class="et_pb_section et_pb_section_2 et_pb_fullwidth_section et_section_regular" >
				
				
				
				
				
				
				<section class="et_pb_module et_pb_fullwidth_header et_pb_fullwidth_header_0 et_hover_enabled et_pb_section_parallax et_pb_text_align_left et_pb_bg_layout_light">
				<span class="et_parallax_bg_wrap"><span
						class="et_parallax_bg"
						style="background-image: url(https://drzycimski.com/wp-content/uploads/2017/09/programmierung.jpg);"
					></span></span>
				
				
				
				<div class="et_pb_fullwidth_header_container left">
					<div class="header-content-container center">
					<div class="header-content">
						
						<h1 class="et_pb_module_header">jQuery galleries</h1>
						<span class="et_pb_fullwidth_header_subhead">Why program yourself? 😉</span>
						<div class="et_pb_header_content_wrapper"></div>
						
					</div>
				</div>
					
				</div>
				<div class="et_pb_fullwidth_header_overlay"></div>
				<div class="et_pb_fullwidth_header_scroll"></div>
			</section>
				
				
			</div></p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-filter-zend_form-input-with-htmlpurifier/">No-MVC Zend Framework: Filter Zend_Form input with HtmlPurifier</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-filter-zend_form-input-with-htmlpurifier/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>No-MVC Zend Framework: Zend_Forms, Decorator, Validator and Filters</title>
		<link>https://drzycimski.com/programmierung/no-mvc-zend-framework-zend_forms-decorator-validator-and-filters/</link>
					<comments>https://drzycimski.com/programmierung/no-mvc-zend-framework-zend_forms-decorator-validator-and-filters/#respond</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Sat, 05 Feb 2011 18:49:27 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[autoloader]]></category>
		<category><![CDATA[bootstrap]]></category>
		<category><![CDATA[Controller]]></category>
		<category><![CDATA[Decorators]]></category>
		<category><![CDATA[Filters]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[View]]></category>
		<category><![CDATA[YAML]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Zend_Form]]></category>
		<guid isPermaLink="false">http://www.drzycimski.com/?p=127</guid>

					<description><![CDATA[<p>Managing Zend_Form in both MVC and no-MVC environments has a huge advantage, since Zend Framework comes with a load of decorators (HTML to display form fields), validators (functions to check user input) and filters (functions to filter user input). If you look for an easy way to handle all kinds of user input thru forms, [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-zend_forms-decorator-validator-and-filters/">No-MVC Zend Framework: Zend_Forms, Decorator, Validator and Filters</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Managing Zend_Form in both MVC and no-MVC environments has a huge advantage, since Zend Framework comes with a load of decorators (HTML to display form fields), validators (functions to check user input) and filters (functions to filter user input). If you look for an easy way to handle all kinds of user input thru forms, ZF is the way to go&#8230; at least if you have a lot of different forms on you website, that is 😉</p>
<p>This articles is based on the first parts of the Star Rating series (which I still have to finish&#8230;), so it assumes you have managed to install ZF on your system, have your bootstrap.php up and running. Pls note: I changed the naming from &#8222;Mylib&#8220; to &#8222;JD&#8220;&#8230; using my initials is easier because I can copy&amp;paste my classes 😉 Just in case: here´s the bootstrap.php that you have to include, already with some new code:</p>
<pre class="brush:php">&lt;?php
// Define path to application directory
defined('APPLICATION_PATH')
 || define('APPLICATION_PATH', ($_SERVER['DOCUMENT_ROOT']));

// Define application environment
defined('APPLICATION_ENV')
 || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
 realpath(APPLICATION_PATH . '/../library'),
 get_include_path(),
)));

/**
 * General PHP settings
 */
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 1);
ini_set('default_charset', 'UTF-8');

/**
 * Autoloader
 */
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
// Register folder library/JD/ for own classes
$autoloader-&gt;registerNamespace('JD_');

/**
 * Load Zend Config from application.ini
 */
$config = new Zend_Config_Ini($_SERVER['DOCUMENT_ROOT'] . '/../library/JD/configs/application.ini', APPLICATION_ENV);
Zend_Registry::set('config', $config);

/**
 * Connect to default DB
 */
$db = Zend_Db::factory($config-&gt;database);
Zend_Db_Table::setDefaultAdapter($db);

/**
 * Get Zend View object (required for any view helpers, e.g. Form, Navigation)
 */
$view = new Zend_View;
$view-&gt;setEncoding('UTF-8');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
// Doctype for Form Renderer
$doctypeHelper = new Zend_View_Helper_Doctype();
$doctypeHelper-&gt;doctype('XHTML1_TRANSITIONAL');

/**
 * Set default language for form errors etc
 */
$translate = new Zend_Translate('array', $_SERVER['DOCUMENT_ROOT'] . '/../library/JD/Languages/de.php', $config-&gt;language-&gt;default);
Zend_Form::setDefaultTranslator($translate);
</pre>
<p>In order to be able to use Zend_Form, you need to set the Zend_View, else it would not render it. The language part is optional, it´s a simple file replacing English error messages with (in this case) German ones. Refer to the ZF manual for language details.</p>
<p>The next part is to set some rendering options, A.K.A decorators. With most websites, I use <a title="YAML CSS framework" href="http://www.yaml.de/" target="_blank" rel="noopener">YAML</a> as a CSS framework, and ZF renders form elements into dt/dd tags (didn´t know anyone uses those anymore&#8230;). Anyway, re-decorating a form is a piece of cake. Create a subfolder &#8222;Form&#8220; in your own &#8222;library&#8220; subfolder (mine is &#8222;JD&#8220; was &#8222;Mylib&#8220;), and create a form controller, named &#8222;Controller.php&#8220;.  If you´ve read the previous articles, you can guess the name of the class&#8230; JD_Form_Controller. Replace the &#8222;JD&#8220; part with anything you like, according to your directory structure (e.g. &#8222;library/somename/Form/Controller&#8220; translates to class name &#8222;somename_Form_Controller&#8230; just basic autoloading knowledge). Here´s what the controller looks like:</p>
<pre class="brush:php">class JD_Form_Controller extends Zend_Form
{
 // COLUMNAR YFORM decorators

 // standard input type=text &amp; textareas
 protected $_standardTextDecorator = array(
   'ViewHelper',
   array('Label', array('escape'=&gt;false)),
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-text')),
   // not used
   array('Description')
 );
 // standard input type=select
 protected $_standardSelectDecorator = array(
   'ViewHelper',
   array('Label', array('escape'=&gt;false)),
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-select')),
   // not used
   array('Description')
 );
 // standard checkbox type=checkbox
 protected $_standardCheckboxDecorator = array(
   'ViewHelper',
   array('Label', array('escape'=&gt;false)),
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-check')),
   // not used
   array('Description')
 );
 // special input type=captcha -&gt; into type-text for styling
 protected $_standardCaptchaDecorator = array(
   'ViewHelper',
   array('Label', array('escape'=&gt;false)),
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-text')),
   // not used
   array('Description')
 );
 // standard input type=hidden w/out tags
 protected $_standardHiddenDecorator = array(
   'ViewHelper'
 );
 protected $_standardButtonDecorator = array(
   'ViewHelper',
   array('HtmlTag', array('class'=&gt;'type-button'))
 );

 // Standard YFORM decorators
 protected $_leftTextDecorator = array(
   'ViewHelper',
   array('Label', array('escape'=&gt;false)),
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-textleft'))
 );
 protected $_fullTextDecorator = array(
   'ViewHelper',
   array('Label', array('escape'=&gt;false)),
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-textfull'))
 );
 protected $_leftCheckDecorator = array(
   'ViewHelper',
   array('Label', array('escape'=&gt;false)),
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-checkleft'))
 );
 protected $_leftButtonDecorator = array(
   'ViewHelper',
   array('HtmlTag', array('tag'=&gt;'div', 'class'=&gt;'type-buttonleft'))
 );

 /**
 * Class constructor
 *
 * @param array $options
 */
 public function __construct($options = null)
 {        
   // path setting for custom classes MUST ALWAYS be first!
   $this-&gt;addElementPrefixPath('JD_Form_Decorator','JD/Form/Decorator','decorator');
   $this-&gt;addElementPrefixPath('JD_Form_Validator','JD/Form/Validator','validate');
   $this-&gt;addElementPrefixPath('JD_Filter','JD/Filter','filter');
   parent::__construct($options);
   $this-&gt;setAttrib('class', 'yform columnar');
   $this-&gt;setDecorators(array(
     'FormElements',
     'Form'
   ));
 }    
}
</pre>
<p>This is a lot at once, but I already set everything up for decorators (defining them and adding the prefix path), validators (still to be defined, but prefixed) and filters (also not defined yet, but prefixed). By default, I use columnar forms on the website (label next to form field: all $_standard* decorators), but also have an option to use labels above their fields ($_left or $_full). E.g. the $_standardTextDecorator wraps an INPUT element, inluding the label, into a DIV with the class &#8222;type-text&#8220;, and wraps the label into a new decorator &#8211; one that appends an * to each required input field.</p>
<p>Next up: Zend_Decorator and Zend_Validator</p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-zend_forms-decorator-validator-and-filters/">No-MVC Zend Framework: Zend_Forms, Decorator, Validator and Filters</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-zend_forms-decorator-validator-and-filters/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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>Google Maps Geocoding with JSON and PHP</title>
		<link>https://drzycimski.com/programmierung/google-maps-geocoding-api-with-json-and-php/</link>
					<comments>https://drzycimski.com/programmierung/google-maps-geocoding-api-with-json-and-php/#comments</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Sat, 29 Jan 2011 11:13:20 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[Geocoding]]></category>
		<category><![CDATA[Google API v3]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<guid isPermaLink="false">http://www.drzycimski.com/?p=115</guid>

					<description><![CDATA[<p>When using maps on a website, Google is clearly the service to go with. If you are using JavaScript only, parsing a JSON response from Google shouldn´t be difficult, but how to use the response in PHP? In this article, I´ll describe how to use Zend Framework components, but with a link to How-To´s with [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/google-maps-geocoding-api-with-json-and-php/">Google Maps Geocoding with JSON and PHP</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When using maps on a website, Google is clearly the service to go with. If you are using JavaScript only, parsing a JSON response from Google shouldn´t be difficult, but how to use the response in PHP? In this article, I´ll describe how to use Zend Framework components, but with a link to How-To´s with standard PHP functions, to</p>
<ol>
<li>Send a request to Google Maps API</li>
<li>Get the response in JSON format (no problem to switch to XML)</li>
<li>Parse the response from Google to a more readable format</li>
<li>And finally, use those values in a PHP script</li>
</ol>
<p>I needed the response for the meta geotags on <a title="surfspot.de" href="http://www.surfspot.de" target="_blank" rel="noopener">surfspot.de</a>, where I use a lot of maps to show the locations of&#8230; surfspots, obviously. The geotag for a spot would be something like this:</p>
<pre class="brush:html">&lt;meta name="geo.region" content="COUNTRY_SHORT-REGION_SHORT" /&gt;
&lt;meta name="geo.placename" content="CITY" /&gt;
&lt;meta name="geo.position" content="LATITUDE;LONGITUDE" /&gt;
&lt;meta name="ICBM" content="LATITUDE, LONGITUDE" /&gt;
</pre>
<p>&#8230; with latitude and longitude known (stored in database) , and city, region and country to find out from Google. Pls find details about HTML geotags on <a title="HTML Geotag on Wikipedia" href="http://en.wikipedia.org/wiki/Geotagging" target="_blank" rel="noopener">Wikipedia</a>. The meaning of the ICBM tag is just hilarious 😀 For details on Google Geocoding, pls refer to their <a title="Google documentation" href="http://code.google.com/intl/en/apis/maps/documentation/geocoding/" target="_blank" rel="noopener">documentation</a>.</p>
<p>Fist, we need the class to query Google:</p>
<pre class="brush:php">class JD_Geocoder_Request
{
 /**
 * @class vars
 */

 // Google´s geocode URL
 public $url = 'http://maps.google.com/maps/api/geocode/json?';

 // Params for request
 public $sensor       = "false"; // REQUIRED FOR REQUEST!
 public $language     = "en";

 // Class vars
 public $response     = '';
 public $country_long = '';
 public $country_short= '';
 public $region_long  = '';
 public $region_short = '';
 public $city         = '';
 public $address      = '';
 public $lat          = '';
 public $lng          = '';
 public $location_type= '';

 /**
 * Constructor
 *
 * @param mixed $config
 * @return void
 */
 public function __construct($config = null)
 {

 }

} // end class
</pre>
<p>I prefer to store all results I may or may not need in class vars, so I can just echo them out.</p>
<p>Second, we need to know what kind of search we need to perform, forward geocoding with an address (say, from a form), or a reverse geocoding search, using lat and lng for the query. I implemented both methods, but pls be aware I didn´t test the forward search&#8230; since I don´t need it yet 😉</p>
<pre class="brush:php">/**
 * Forward search: string must be an address
 *
 * @param string $address
 * @return obj $response
 */
 public function forwardSearch($address)
 {
   return $this-&gt;_sendRequest("address=" . urlencode(stripslashes($address)));
 } // end forward

 /**
 * Reverse search: string must be latitude and longitude
 *
 * @param float $lat
 * @param float $lng
 * @return obj $response
 */
 public function reverseSearch($lat, $lng)
 {
   return $this-&gt;_sendRequest("latlng=" . (float) $lat . ',' . (float) $lng);
 } // end reverse
</pre>
<p>Both methods handle formatting the parameters, as well. If you want to handle just the response object, you can skip ahead and ignore the next functions. As said earlier, I like to store the response in class vars in order to just echo them out, or store them in a database. The two functions set the defaults I need to know, and search for other values as well. Pls note that only the response object $address_components is used for the search, Google may or may not return a lot more &#8211; check their docs for this.</p>
<pre class="brush:php">/**
 * Search Address Components Object
 *
 * @param string $type
 * @return object / false
 */
 public function searchAddressComponents($type) {
   foreach($this-&gt;response-&gt;results[0]-&gt;address_components as $k=&gt;$found){
     if(in_array($type, $found-&gt;types)){
       return $found;
     }
   }
   return false;
 }

/**
 * Parse JSON default values: map object values to readable content
 *
 * @param none
 * @return none
 */
 private function _setDefaults()
 {
   $country = $this-&gt;searchAddressComponents("country");
   $this-&gt;country_long    = $country-&gt;long_name;
   $this-&gt;country_short    = $country-&gt;short_name;
   $region = $this-&gt;searchAddressComponents("administrative_area_level_1");
   $this-&gt;region_long = $region-&gt;long_name;
   $this-&gt;region_short    = $region-&gt;short_name;
   $city = $this-&gt;searchAddressComponents("locality");
   $this-&gt;city    = $city-&gt;short_name;
   $this-&gt;address = $this-&gt;response-&gt;results[0]-&gt;formatted_address;
   $this-&gt;lat = $this-&gt;response-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat;
   $this-&gt;lng = $this-&gt;response-&gt;results[0]-&gt;geometry-&gt;location-&gt;lng;
   $this-&gt;location_type = $this-&gt;response-&gt;results[0]-&gt;geometry-&gt;location_type;
 } // end set
</pre>
<p>The JSON response from Google is likely to change, so you need to control the mapping every now and then. If you use the reverse geocoding, pls note that lat and lng may NOT be the same values you used to call the search with, but refer to the next best address, even if location_type is returned as &#8222;rooftop&#8220;. This doesn´t matter if you search on land, but surfspots might be 500m down a beach from a known location, at least, known to Google.</p>
<p>Now for the slightly more difficult part&#8230; the actual request to Google Maps API, and parsing the JSON response. Using the Zend Framework, sending a request to Google is a tad bit easier than using pure PHP. If you don´t use ZF and/or use XML response format, check <a title="phpRiot article" href="http://www.phpriot.com/articles/google-maps-geocoding" target="_blank" rel="noopener">this article</a> on phpRiot, and replace the $client code.</p>
<pre class="brush:php">/**
 * Send Google geocoding request
 *
 * @param string $search
 * @return object response (body only)
 */
 private function _sendRequest($search)
 {
   $client = new Zend_Http_Client();
   $client-&gt;setUri($this-&gt;url . $search . '&amp;language=' . strtolower($this-&gt;language) . '&amp;sensor=' . strtolower($this-&gt;sensor));
   $client-&gt;setConfig(array(
     'maxredirects' =&gt; 0,
     'timeout'      =&gt; 30));
   $client-&gt;setHeaders(array(
     'Accept-encoding' =&gt; 'json',
     'X-Powered-By' =&gt; 'Zend Framework GEOCMS by Joerg Drzycimski'));
   $response = $client-&gt;request();
   $body = $response-&gt;getBody();
   $this-&gt;response = Zend_Json::decode($body, Zend_Json::TYPE_OBJECT);
   if ($this-&gt;response-&gt;status == "OK") {
     // set some default values for reading
     $defaults = $this-&gt;_setDefaults();
     return $this-&gt;response;
   } else {
     echo "Geocoding failed, server responded: " . $this-&gt;response-&gt;status;
     return false;
   }
 } // end request
</pre>
<p>Now that you have the request up and running, the code requirde to generate the meta geotags is quite simple:</p>
<pre class="brush:php">$georequest = new JD_Geocoder_Request();
$lat = '54.424899';
$lng = '11.096671';
$georequest-&gt;reverseSearch($lat,$lng);
echo '&lt;meta name="geo.region" content="' . $georequest-&gt;country_short . '-' . $georequest-&gt;region_short . '" /&gt;';
echo '&lt;meta name="geo.placename" content="' . $georequest-&gt;city . '" /&gt;';
echo '&lt;meta name="geo.position" content="' . $lat . ';' . $lng . '" /&gt;';
echo '&lt;meta name="ICBM" content="' . $lat . ',' . $lng . '" /&gt;';
</pre>
<p>Links: <a href="https://drzycimski.com/wp-content/uploads/2011/01/Request.zip">Class File</a> as ZIP.</p>
<p>The post <a href="https://drzycimski.com/programmierung/google-maps-geocoding-api-with-json-and-php/">Google Maps Geocoding with JSON and PHP</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://drzycimski.com/programmierung/google-maps-geocoding-api-with-json-and-php/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Converting a MySQL database to UTF-8</title>
		<link>https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/</link>
					<comments>https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/#comments</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Thu, 20 Jan 2011 17:11:45 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[charset]]></category>
		<category><![CDATA[convert database]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[utf-8]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<guid isPermaLink="false">http://www.drzycimski.com/?p=110</guid>

					<description><![CDATA[<p>I just spent about 2 days to convert my old MySQL database from latin1 / latin1_general_ci to UTF-8 character encoding. There are about a gazillion pitfalls, especially when you work on old PHP code mixed with ZF code, on a live site of a client. The first tip is&#8230; do NOT work on a live [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/">Converting a MySQL database to UTF-8</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I just spent about 2 days to convert my old MySQL database from latin1 / latin1_general_ci to UTF-8 character encoding. There are about a gazillion pitfalls, especially when you work on old PHP code mixed with ZF code, on a live site of a client. The first tip is&#8230; do NOT work on a live site 😉 Backup everything to a local version or a testserver, and then start to code! Fortunately, I had the site including the database on a local XAMPP environment.</p>
<p>For a coarse orientation, you can use the <a href="http://codex.wordpress.org/Converting_Database_Character_Sets">article on wordpress.org</a> to get an overview. There is no way to change the character encoding of an entire database with just a few keystrokes, so expect it to take a tad bit longer.</p>
<p>For me, the following steps did the trick, using <a href="http://www.phpmyadmin.net/" target="_blank" rel="noopener">phpMyAdmin</a> and <a href="http://www.notepad-plus-plus.org/" target="_blank" rel="noopener">Notepad++</a> (on Windows):</p>
<ol>
<li>Create a backup of the entire database with phpMyAdmin.</li>
<li>Change your database to UTF-8 (ALTER DATABASE mydb CHARACTER SET utf8;). This will only affect new tables, so you´re not thru yet.</li>
<li>Select the table(s) to change, and use the export function of phpMyAdmin.</li>
<li>Copy the exported data (INSERT INTO&#8230;) without the header (CREATE&#8230;) into Notepad++.</li>
<li>Change the table´s charset (ALTER TABLE mytable DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;).</li>
<li>Change all fields with latin charsets to utf8_general_ci (e.g. ALTER TABLE mytable CHANGE myfield myfield TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;). Pls note that this SQL only works for TEXT fields, refer to the <a href="http://codex.wordpress.org/Converting_Database_Character_Sets">article on wordpress.org</a> on how to convert ENUM, VARCHARS and so on, or use phpMyAdmin to do so for you. If you have a lot of columns with the same format to convert, just copy&amp;paste one SQL line, and change the column names in each. Paste those lines into phpMyAdmin´s SQL editor, that´s a lot faster than doing it for each column.</li>
<li>By now, you should have the table as well as all columns in UTF-8.</li>
<li>Switch to Notepad++, where all you INSERTs for that table are, and convert those lines to UTF-8.</li>
<li>Copy&amp;paste it into phpMyAdmin´s SQL editor.</li>
<li>Repeat steps 3 to 9 for each table, and you should have your database converted to UTF-8.</li>
</ol>
<p>Now, that took an hour or two ;), but there´s still the website to change to the new encoding.</p>
<p>First, start with your meta tag:</p>
<pre class="brush:html">&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
</pre>
<p>Next up, if applicable, change your database connection script in PHP:</p>
<pre class="brush:php">mysql_set_charset("utf8");
</pre>
<p>And / or if you use Zend Framework, edit your config file:</p>
<pre class="brush:php">database.params.charset = "utf8"
</pre>
<p>and your bootstrap:</p>
<pre class="brush:php">ini_set('default_charset', 'UTF-8');

$view-&gt;setEncoding('UTF-8');
</pre>
<p>That should do the trick, and your entire site runs on UTF-8 instead of latin.</p>
<p>The post <a href="https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/">Converting a MySQL database to UTF-8</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://drzycimski.com/programmierung/converting-a-mysql-database-to-utf-8/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>No-MVC Zend Framework: jQuery Ajax receiver / Part V</title>
		<link>https://drzycimski.com/programmierung/no-mvc-zend-framework-jquery-ajax-receiver-part-v/</link>
					<comments>https://drzycimski.com/programmierung/no-mvc-zend-framework-jquery-ajax-receiver-part-v/#respond</comments>
		
		<dc:creator><![CDATA[Jörg]]></dc:creator>
		<pubDate>Tue, 11 May 2010 16:34:31 +0000</pubDate>
				<category><![CDATA[Programmierung]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Star Rating]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<guid isPermaLink="false">http://blog.drzycimski.com/?p=64</guid>

					<description><![CDATA[<p>The jQuery JavaScript is up and running, but needs a PHP file to handle the Ajax data submitted by the rating script. This will be done with PHP in the receiver you defined in your JavaScript, named &#8222;rating.php&#8220; in the &#8222;public/includes&#8220; folder. It&#8217;s important to put this PHP file in your public folder, because if [&#8230;]</p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-jquery-ajax-receiver-part-v/">No-MVC Zend Framework: jQuery Ajax receiver / Part V</a> appeared first on <a href="https://drzycimski.com">Jörg Drzycimski</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>The jQuery JavaScript is up and running, but needs a PHP file to handle the Ajax data submitted by the rating script. This will be done with PHP in the receiver you defined in your JavaScript, named &#8222;rating.php&#8220; in the &#8222;public/includes&#8220; folder. It&#8217;s important to put this PHP file in your public folder, because if you pointed your webserver to &#8222;public&#8220;, anything outside (subfolders of  your document root) can&#8217;t be accessed by JavaScript.</p>
<p>Create the &#8222;rating.php&#8220;, and add the following lines:</p>
<pre class="brush:php">&lt;?php
require_once('bootstrap.php'); // Setup Zend Framework Environment
header("Cache-Control: no-cache");
$rating = new Mylib_Rating_Controller();
$score = $rating-&gt;setRatingById($_GET['id'], $_GET['val']); // rate object and get scores
echo Zend_Json::encode($score); // send response array in JSON format
?&gt;
</pre>
<p>The <code>setRatingById</code> passes the values from your JavaScript to the (soon to be created) controller, and receives the updated values from your (soon to be created) database. When I started out using jQuery in combination with Ajax, I was kind of afraid to find it difficult&#8230; but it really<em> is </em>that easy 😉</p>
<p>Next up: The rating controller</p>
<p>The post <a href="https://drzycimski.com/programmierung/no-mvc-zend-framework-jquery-ajax-receiver-part-v/">No-MVC Zend Framework: jQuery Ajax receiver / Part V</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-jquery-ajax-receiver-part-v/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>
