php / symfony — No comments
29
Jun 10
The Symfony PHP Framework has, in the past, alienated a lot of developers solely because it was quite a hassle to setup on shared hosting or a local server environment.
What’s new in Symfony 2.0?
- Requires PHP5.3.2+
- Doctrine 2 (Active Record is replaced by Entity Pattern, completely rewritten codebase for PHP5.3)
- PHPUnit for testing, lime is out for good
- Logging and caching with Zend Framework
- Access to remote APIs (web services, feeds, etc.)
- Support for Lucene indexes
- PDf generation
- Queueing
- Cloud computing (storage, DBs, message queues)
- Forms2, the new form framework
- Web Debug Toolbar
You can setup the symfony 2.0 sandbox on a local server in 7 steps under a local MAMPP environment on a Mac.
The symfony sandbox is a Symfony project where all the required libraries and some simple controllers are already included and where the basic configuration is already done.
- Download the sandbox
- Unpack sandbox in your htdocs folder
- Check your local server environment with http://localhost:8888/sandbox/web/check.php
- Check a first webpage in the development environment at http://localhost:8888/sandbox/web/index_dev.php/
- The sandbox comes with a simple “Hello” app at http://localhost:8888/sandbox/web/index_dev.php/hello/Reinhold%20Weber
- Explore the web developer toolbar at the bottom (only available in the dev environment under index_dev)
- Configure a virtual host in conf/apache/httpd.conf which points to the sandbox/web/ directory
Welcome to Symfony2.0, available in late 2010 – enjoy the ride. More on the new Symfony version soon.
joomla / php — No comments
28
Jun 10
Create you first Joomla 1.6 module completely from scratch.
Joomla, as of version 1.5 which was a complete rewrite is based on the MVC design pattern which makes creating modules extremely easy and structured. Joomla 1.6 changes a few things, the basics however remain the same.
- Create a folder called mod_helloworld in modules
- Create a mod_helloworld.php file
- Create a mod_helloworld.xml file
- Create a helper.php file
- Create a template file tmpl/default.php
- Discover new modules by going to “Extension Manager” -> “Discover”
The code for mod_helloworld.php
<?php
defined('_JEXEC') or die; // no direct access allowed
require_once dirname(__FILE__).DS.'helper.php'; // get helper files
$hello = modHelloWorldHelper::getHello($params);
require JModuleHelper::getLayoutPath('mod_helloworld');
?>
The helper.php file
<?php
class modHelloWorldHelper
{
/**
* Retrieves the hello message
*
* @param array $params An object containing the module parameters
* @access public
*/
function getHello( $params )
{
return 'Hello, World!';
}
}
?>
Include the template file for the default view
<?php
defined('_JEXEC') or die;
echo $hello;
?>
The helloworld.xml file
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="1.6.0" client="site" method="upgrade">
<name>Hello World!</name>
<author>Reinhold Weber</author>
<version>1.6.0</version>
<description>Reinholds simple Hello World module.</description>
<files>
<filename module="mod_helloworld">mod_helloworld.php</filename>
<filename>mod_helloworld.xml</filename>
<filename>index.html</filename>
<filename>helper.php</filename>
<filename>tmpl/default.php</filename>
<filename>tmpl/index.html</filename>
</files>
<params>
</params>
</extension>
Create both index.html files to prevent direct directory browsing
<html><body></body></html>
drupal / php — No comments
28
Jun 10
Create your first Drupal 7 module with the following steps.
- Create a folder called helloworld in sites/all/modules/custom
- Create a helloworld.info file
- Create a template file page-helloworld.tpl.php in your theme directory
- Enable your module at http://domain.com/admin/build/modules
- Visit http://domain.com/helloworld
This belongs into your helloworld.info file
; $Id$
name = helloworld
description = Reinholds Hello World module
package = Reinholds modules
core = 7.x
files[] = helloworld.module
The helloworld.module file
<?php
function helloworld_menu(){
$items = array();
$items['helloworld'] = array(
'title' => t('Hello world'),
'page callback' => 'helloworld_output',
'access arguments' => array('access content'),
);
return $items;
}
/*
* Display output
*/
function helloworld_output() {
header('Content-type: text/plain; charset=UTF-8');
header('Content-Disposition: inline');
return 'helloworld';
}
?>
The theme template file page-helloworld.tpl.php
drupal / php — No comments
28
Jun 10
In Drupal 6 you had to target IE specific CSS files by adding lines to your page.tpl.php or use an additional module which allows you to target browsers inside your theme.info file.
In Drupal 7 however, the recommended way is by using the use drupal_add_css() function in your template.php file.
function mytheme_preprocess_html(&$vars) {
drupal_add_css(path_to_theme() . '/fix-ie.css', array('weight' => CSS_THEME, 'browsers' => array('IE' => 'lt IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
}
Uncategorized — No comments
28
Jun 10
Welcome to my new blog. The old one got old, so I decided to start with a clean slate. If you came here looking for an old post, I’m very sorry, that’s life I guess, out with the old, in with the new.
I’m a web developer working with Drupal, Joomla, WordPress, Zend Framework and Magento so this is what I will write about most of the time.
With new major versions of my favorite cms (WP3, Drupal 7 and Joomla 1.6) dropping on the internets this summer there will be a lot to talk about.
Enjoy & happy coding