Tag: frameworks
Installing Symfony with XAMPP running Windows Vista
by Phil Hawthorne on Feb.02, 2011, under Development, PHP
There are many different PHP frameworks out there. From the complex (Zend) to the light-weight and basic (CodeIgniter), each come with their own pros and cons.
Tonight I’ve finally taken the plunge to try and install a different PHP Framework for my new project I hope to start this year. Having used CodeIgniter for my projects since completing my Diploma, I think it’s time I start venturing out, and see some of the features other Frameworks have to offer. One Framework I’ve seen discussed and mentioned heaps is Symfony. I’ve seen many-a-job post requesting Symfony experience. So I think before I head further down the rabbit hole with drupal, Symfony is the next step to take.
One feature I love about CodeIgniter is its easy to install. Extract the files, and it’s working. After all, it’s just a website with some PHP scripts. However as I quickly discovered, Symfony is not that easy at all.
CodeIgniters Image Library
by Phil Hawthorne on Jul.01, 2010, under Development, PHP
Frameworks can make a developers life and job a lot simpler, but that doesn’t mean they don’t come with their own headaches and hours of frustration.
Tonight I’ve been coding an image uploading script using the CodeIgniter PHP Framework. This was the first time I’ve used the built-in image library to help me cut down my coding time.
Following the user guide at http://codeigniter.com/user_guide I was attempting to load an image that had been saved to the server, from the file uploading class. The example on the website uses the following example code:
$config['image_library'] = 'gd2';
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
This code actually doesn’t work, and will result in an error “Your server does not support the GD function required to process this type of image”.
Why doesn’t it work?
As posted on the CodeIgniter Forums by user ‘gunter’, you shouldn’t loop through
$this->load->library('image_lib', $config);
Instead what you should do is:
$this->load->library('image_lib');
// Set your config up
$this->image_lib->initialize($config);
// Do your manipulation
$this->image_lib->clear();
(courtesy of a.somervell)
A lesson to show you that not even the documentation can always be correct. Hopefully this saves some people hours of pulling their hair out.