Curl with PHP 5.2.9-2 and Apache 2.2.11 on Windows XP

This is a quick follow up post from Tony Spencers post “cURL with PHP and Apache on Windows.” I’d like to thank him for sharing his knowledge.

The reason i wanted to post this is to clear up any confusion you about getting Curl to work on Windows XP (with PHP 5.2.9-2 and Apache 2.2.11). Most likely this solution will work with all versions of PHP5 and Apache 2.2.x and if you are running XAMPP you can check how easy it is to >> enable << .

Getting Curl to Work!!

  1. First thing to do is to have the development environment installed locally on your computer. I have one at the office with installed without the installer and one here at home with the installer. For all intensive purposes lets concentrate on using php/apache installed with the MSI installer. If you got that going thats great, if not head on over to this >> Tutorial to install your local development << (the manual way with the installer) If you got it installed already head on over to the next point
  2. Next thing you need to do (after your installation) is to check your phpinfo() file. If you don’t have one make one and load it up on your local web-server. It should look like the screen below:
    Php.ini showing Curl extension

    If you don’t see your Curl extension in phpinfo() after trying to find it I suggest you install php again using the installer. Make sure your ENABLE all extensions/features in your installation as you will get an option to do so. (install all features please) If you explore the extension features in your install dialogue box you will see CURL there. This my friends is the key to the problem. If the installer gives you the option for less headache then use it. Did I mention that you can also rerun the installer and choose “Change”, then add the CURL extension?!

  3. Once you have installed properly and find the Curl extension in your phpinfo() screen make sure to copy these files from your PHP root directory (mine was D:\Program Files\PHP) to your c:\windows\system32:
    libeay32.dll
    ssleay32.dll

    Also make sure that a copy of php5ts.dll is also in your Apache/bin directory
  4. Last step is to uncomment this line curl: extension=php_curl.dll in your php.ini file. That should do it for you and hopefully everything worked out right!
  5. To test that Curl is actually working use this snippet of code and drop it in to your server root (usually htdocs):
    [php]

    [/php]

    Try this as well to display feeds from your blog (where $sXML = show_feeds(‘put the url of your blog here/atom’)
    [php]
    foreach($oXML->entry as $oEntry) {
    echo $oEntry->title . “\n”;
    }
    ?>
    [/php]

  6. If you see the the rss feed of Google then you are done! Change the output to ‘html’ and you will see the RSS feed displayed properly in html.

Scripting Twitter with cURL via Command Line

Ok the above explanation shows you how to use Curl and PHP together to build applications based on API’s that you would like to hook into. It doesn’t mean that you have Curl installed in your command like prompt where you can actually see the XML.

To do that is quite simple. Go over to http://curl.haxx.se/download.html and download the the Win32 Generic (7.19.4) by Dirk Paehl. Go ahead and extract it to a local folder (I extracted it to D:\Program Files\Curl).

Next open up the command prompt and cd into the same directory you extracted it into. Now just type in curl at the prompt to make sure the command is recoginized
Curl at the CMD line

If you want to easily overcome the shortcomings of Twitter’s API us this command below:

curl --basic --user username:password --data status="Checking out Curl!!" http://twitter.com/statuses/update.xml
//replace username:password with your user name and password

You should end up with this below:
Scripting status update

So by now you should have a good idea of how Curl works with Apache and PHP as well as on the command line. The way i explained above should work straight out of the box. Good Luck!

Awesome! – Portable Ubuntu Shell In Windows (XP, Vista, 7)

Portable Ubuntu

So you have heard of Linux and one of its most popular flavors (Ubuntu) and want to try it out on your Windows system? (Most people probably don’t know what Linux is and where it came from.) So, if you are new to Linux I just wanted to quickly mention that the name is derived from Linus Torvalds (the creator of Linux) a kick-ass Software Engineer and Computer Scientist from Finland. Learn more about him!

To make a long story short Ubuntu is a community developed operating system that is perfect for laptops, desktops and servers. Whether you use it at home, at school or at work Ubuntu contains all the applications you’ll ever need, from word processing and email applications, to web server software and programming tools.

Ubuntu is and always will be free of charge. You do not pay any licensing fees. You can download, use and share Ubuntu with your friends, family, school or business for absolutely nothing.

INSTALLING PORTABLE UBUNTU ON WINDOWS XP

The installation procedure is simple enough. Goto http://portableubuntu.demonccc.com.ar/ and download from the Souce Forge Site.

Next drop that application file into your local hard-drive or on a USB or flash drive (choice is yours). Run the application (Double click on the Portable_Ubuntu.exe icon and it will self extract).

Lets stick to the easiest way to get started. Once you have extracted the files either use your CMD prompt (Command Line Prompt) to run the portable_ubuntu.bat file or double click on portable_ubuntu.bat to start the Operating System. The portable_ubuntu.bat can be found where you extracted the application.

Once you have done that you should see screens similar to the one below of the installation process. Dont worry about any errors at this stage, it should work straight out of the box.
Screenshot of Install process

All you have to do after the install is complete is to watch out for the rectangular Ubuntu Dockable Palette on your desktop – it looks just like the screen below. You can drag it around and Portable Ubuntu lets you work with Dual monitors too!

Dockable Floating Window

Thats it you are done. Now you can have an Ubuntu Shell right in your Windows operating system. Note that Portable Ubuntu does work on Windows Vista and Seven, however you have to log on as the administrator to prevent security issues.

Check out some of these links as a reference in case you run into problems:

http://lifehacker.com/5195999/portable-ubuntu-runs-ubuntu-inside-windows
http://portableubuntu.demonccc.cloudius.com.ar/documentationhttp://www.pendrivelinux.com/portable-qemu-persistent-ubuntu-linux/
www.howtoforge.com/running-ubuntu-on-windows-xp-with-portable-ubuntu

Class Declarations in Rails Migrations

This is an unforgettable mistake i made today while running some migrations in Rails.

Here is the first migration file. It was generated by using this simple command:

ruby script/generate model Articles

Simple enough right? The output of the generation was:

When i went ahead and tried the rake command to migrate to my database: rake db:migrate I kept getting an error “Uninitialized constant Create Articles” Rake Aborted!!

Having forgot that everything in Rails is Object Orientated (extends from one base class or another) i overlooked two things.

  1. I did not declare the class and what base it extended
  2. I did not add the schema file name into my migration file

Usually Rails generates the schema and adds the base class (Active Record) but this time it didn’t. Anyhow the fix was easy enough…

So this is a classic mistake of us all having our moments..Thanks again to the users over at Stack Overflow for helping out. Their are some excellent trouble shooters out there.

Installing Ruby on Rails

Since Ruby on Rails was first released, it has become a household name (in developers’ households, anyway). Hundreds of thousands of developers the world over have adopted—and adored—this new framework. Firstly Ruby is a programming language which was written by a Japanese man Yukihiro “Matz” Matsumoto. Ruby on Rails is the Framework for Ruby and is used to build web based applications.

We will deal with manual installation techniques and use the command-line and installers for specific tasks as well as configure Instant Rails.

Continue reading

Installing APACHE 2.0.6 / PHP5.2.6 for Windows

BRIEF HISTORY OF APACHE (As written on Wikipedia)

The Apache HTTP Server, commonly referred to simply as Apache [??pæt?i], is a web server notable for playing a key role in the initial growth of the World Wide Web. Apache was the first viable alternative to the Netscape Communications Corporation web server (currently known as Sun Java System Web Server), and has since evolved to rival other Unix-based web servers in terms of functionality and performance.

It is often said that the project’s name was chosen for two reasons: (1) out of respect for the Native American Indian tribe of Apache (Indé), well-known for their endurance and their skills in warfare, (2) and due to the project’s roots as a set of patches to the codebase of NCSA HTTPd 1.3 – making it “a patchy” server.
Continue reading