Moving Beyond SSH: Subversion

Published on Jul 5, 2009   //  Development
Off

Moving Beyond SSH

Subversion is an open-source version control system for source code. Subversion (often appreciated as SVN) is used commonly in the open-source software world. Large project such a WordPress use SVN to keep track of revisions and manage different development versions of the source code.

Today we’ll be installing Subversion. Before we install Subversion, however, we need to recompile Apache to include the mod_dav module. Assuming you still have your original Apache directory (that you installed it from originally), cd into there. If you no longer have it, simply redownload and extract Apache. Now, run the following commands:

./configure --enable-so --enable-rewrite --enable-deflate --enable-headers=shared --enable-expires=shared --enable-dav
make
make install
apachectl -k restart

Next, we need to install some dependancies that Subversion requires to run. Run the following command to install the dependancies. You may already have some of these installed on your system, but that’ll be fine.

yum install sqlite expat expat-devel neon neon-devel

We can now install Subversion. Begin with downloading the latest .tar.gz from this page. Next, extract the archive:

tar -zxf subversion-1.6.3.tar.gz

Sub in the appropriate file name for the version of Subversion you downloaded. Next cd into that directory.

Now, run these commands to install Subversion:

./configure
make
make install

After that has finished, open your httpd.conf file (located in /usr/local/apache2/conf/ and add the following line (if they weren’t already added automatically):

LoadModule dav_svn_module modules/mod_dav_svn.so
LoadModule authz_svn_module modules/mod_authz_svn.so

Next week we’ll be going over how to configure Subversion repositories and the two different ways to do so.

WordPress Development: The Loop

Published on Jul 4, 2009   //  Development
Off

WordPress Development

A vital part of a WordPress theme is commonly know as the loop. The loop is a while loop that loops through the available post for the requested page and displays them. Although it may seem counterintuitive, the loop is also used for single blog posts and pages. This is simply to have one function which can handle all the different types of media.

The loop is made up of a couple of different functions. The function that the loop is actually based upon is have_posts(). Which sets up the way for another function, the_post(), which will set up for other functions to output the current content to the browser. The “output functions” include the_permalink(), the_title(), the_time(), the_author(), the_content(), the_tags() and the_category(), which are fairly self-explanatory. Others also exist, but these are the main functions. Let’s take a look a basic loop (edited for simplicity):

[code language="php"]if (have_posts()) {
while (have_posts()) {
the_post();
// Post output here
}
else {
// Nothing found
}[/code]

As you can see, we first check if have_posts() is true (if there’s no posts to display, it will return false). We then use a while loop with have_posts() as the expression. Inside the loop, we run the_post(), which basically sets up a reference for the output functions to work off of.

There you have it, a basic version of the loop. If you want more complete examples of the loop in action, I would recommend checking out the default theme of WordPress. Specifically, the index.php, single.php and page.php files.

Everything PHP: Creating a Database

Published on Jul 1, 2009   //  Development

Everything PHP

Now that we have gone over database structures and field types, we can finally create our database. Once we have created our database, we can begin to go over how to interact with the MySQL server using PHP.

The process to create a database will vary depending on your host. However, the basic premise is the same. You create a database along with a MySQL username and password (choose a strong, randomized password). You then associate the MySQL user with the database. Once you have done that, you MySQL database now exists.

However, your database is basically useless, as you currently have no structure to store any data in. To begin adding in your structure, you’ll have to move over to a different tool, which is usually phpMyAdmin. Once you’re in phpMyAdmin, you can begin creating tables and fields in your database.

If you ever get stuck on what field type you should use, refer to the MySQL documentation for an explanation. Get your database all setup and ready for next week, when we’ll be getting into the integration between PHP and MySQL.

Moving Beyond SSH: Message of the Day

Published on Jun 26, 2009   //  Development

Moving Beyond SSH

With Linux/Unix, it is possible to set a Message of the Day (MOTD) that will displayed upon a successful login to the system. While the name is a bit misleading, in the sense that the message doesn’t automatically change each day. Rather, it is intended for you to change it when you feel there is something you need to inform those who are logging in about (or just for fun).

While setting a login message probably isn’t useful if you’re the only one logging into your server, it can be useful if you have multiple people that login. Feel free to set one just for fun though. :)

Setting a login message is simple. Login to your server via SSH and open the file /etc/motd. You can then enter anything you like into that file (including line breaks). Save and close that file once you’re done. Now, everytime you login, you’ll see that message. Changing the message is as simple as change the contents of the file to reflect what you want the login message to be.

Everything PHP: MySQL Field Types

Published on Jun 24, 2009   //  Development
Off

Everything PHP

With MySQL, there are a variety of different types of fields. These types of fields correlate to the type of data that will be stored within them. By defining what type of data you will be storing within a field, you give MySQL a better idea of how to handle queries to this data, and you also open up some other possibilities within MySQL.

There are a couple of different categories of types: numeric, date and time and string. Numeric types of data include things such as integers, floats, decimals and boolean values. Date and time types are special MySQL formatted fields that can include the date, the date and time, a unix timestamp (in a MySQL format) or a year. String data fields include text, “blobs”, specific sets of possible values, variable characters strings and more.

There are far to many different types to be able to define them all here. However, the MySQL Reference Manual has some extensive documentation of data types, which is a good place to start learning about them. Once have learned the different data types, you can then factor them into your database structure plan.

Next week we’ll be taking our database structure and making it into a database. We’ll use what we’ve learned about proper structures and data field types to create our efficient and expandable database.

Web Development: Introduction to Ajax

Published on Jun 23, 2009   //  Development
Off

Web Development

Ajax (which stands for Asynchronous Javascript and XML) is the technology behind many “Web 2.0″ applications. Ajax is used to exchange data with the server in the background, without the need to refresh the page. Ajax creates a more seamless experience for the user, making the web application feel more like a desktop application.

Ajax is used extentively in many of the websites you (probably) visit daily. Web sites such as Gmail, Google Reader, Twitter and even the administration of WordPress using Ajax throughout. Without Ajax, these web sites would be much slower and clunkier to use. Which would, effectively, ruin the simulated experience of using a desktop application.

Ajax’s concept is fairly simple. Using Javascript, data is sent or requested to/from a server, which then returns back something. Still using Javascript, that return from the server is then used to replace (or add to) what the current page is displaying. Basically you can change the whole page, without requiring the page to reload. Ajax is invisible to the user, and most actions can be carried out in less than one second, recreating the desktop experience – on the web.

However, Ajax exists differently in different browsers, creating a lot of extra cross-browser scripting required in Javascript. To make Ajax seem less daunting, and easier to achieve, we’ll be showing you how to do it in jQuery. jQuery greatly simplifies the process, making it easier for you.

Page 9 of 42« First...7891011...203040...Last »