Posts Tagged PHP

Codeigniter Controllers Give Server 404

I often take shortcuts when setting up my development servers. I recently installed Linux Mint 12 x64 on my main box and wanted to setup a web developing environment on it. To cut corners during package installation, I'll typically install phpmyadmin which grabs most of the dependencies I need to have a full LAMP dev stack, such as Apache2 and Mysql-server.

That's how I initially set up my stack in Linux Mint. I also enabled user directories in Apache so I could develop within the public_html directory inside my home directory. All was working well until I copied a CodeIgniter project over and tried it out. I couldn't access my controller functions from index.php. It worked well for the default controller because it was accessing it from index.php, but when I changed the URL to point to a controller like index.php/admin, it didn't know what to do with it and I would receiver a server 404 error.

After digging around for a solution, I realized that when I installed my LAMP stack, apt had installed libapache2-mod-php5filter instead of libapache2-mod-php5. I'm not very familiar with this module or what benefits come from using it, but the quick fix was to:

sudo apt-get install libapache2-mod-php5

This removed the php5filter module and installed the plain php5 module. After that, I no longer have an issue with the controllers giving 404 errors.

»crosslinked«

, , , , ,

No Comments

PHP Video Tutorials

I just started a new website devoted to teaching people how to develop websites. The site is PHP Video Tutorials. So far I have about 20 videos uploaded. There are nine in the first series which teaches basic HTML and CSS. The second video series goes into PHP and MySQL. I think these videos will be very helpful to anyone who wants to get into web development.

, , , , , ,

No Comments

The Best PHP Framework?

I've been really interested in using a PHP framework. One thing holding me back is deciding which one to work with. It seems that every time I start looking at frameworks, I end up deciding to just code everything manually. The major contenders seem to be Yii, Zend, Symfony, CakePHP, and CodeIgnitor. However, I have no idea which one I'm going to use. It's hard to decide without learning the ins and outs of each one and making a good decision based on that knowledge.

My latest attempt was with the Zend framework. I was getting into it and realized that most of the documentation for setting it up bases the setup from a virtual host in Apache. This would be fine, but it actually makes development and deployment overly complicated for me. My development environment is a Linux machine that is my main desktop. My production server is my own dedicated server with CPanel. Zend doesn't work very well with this setup from what I can tell.

I want my site to transfer easily between the two environments. I like them to be self-contained as well. I want to throw the framework into a lib folder or link to it in some way. I don't like that the forward-facing web site is in the "public" folder. I want the root of the website to be the forward-facing public website.

I would really like to use Zend because it has a lot of good extensions for utilizing various web services.

I'd like to hear from others. Which framework would you recommend and why?

, , , , ,

No Comments

AJAX Cross Domain Work-around

Any of you that are AJAX developers can skip this post. I've just recently started concentrating on AJAX for a project I'm working on. In the past, I've used PHP to parse XML returned from various web services and it goes off without a hitch. I also wrote my own web service in PHP for this project.

The project is basically a site that works with the eBay API to pull the most watched items for any keyword search phrase and by category. I've pulled all the categories to a local database. This will allow me to avoid using an API call every time someone clicks through different categories. All the categories are in an AJAX menu system I wrote. The menu is completely dynamic and loads the categories and subcategories using calls to my web service. This part was fun because it gave me the opportunity to create a web service and this in itself was worth the time I've spent on the whole project.

I ran into a road block however, because I wasn't aware that AJAX doesn't allow cross-domain calls. At least from what I see, it doesn't. I started getting an error 1012 "Access to restricted URI denied'." This means that the actually calls I would like to make to the eBay API won't work through AJAX. I wrote the code to try to do so and kept getting this error. That's when I found out that it wasn't possible to do this using AJAX. It's fine in PHP, however. So, here is the work-around I'm brain-storming. I know it'll work. It's just a matter of doing it.

The work-around is simply to write another web service in php that makes the calls for me. Then use AJAX to pull the info dynamically from the localhost. The up side to this is I can also log various stats about the calls within the web service as well. I could create a table in my database to log the searches, time of day, IP address of user, and so on. This will allow me to understand how the app is being used, who's using it, when they are using it, and what they are using it for.

This is also known as using AJAX through a proxy. Where the proxy is the web service on the localhost from which one can make an AJAX call to.
So, I'm off to code another web service.

, ,

No Comments