GitHub is a great, free service that lets you share your Git repositories online with others. In this tutorial, Blake gives a quick tour of our Git Series Example GitHub project, and then explains how pull requests work, letting you merge changes into the repository through the UI. Feel free to try it out by adding jokes to our new jokes.txt file!
This tutorial takes a look at applying a patch from Drupal.org to your local copy of a module or Drupal core using Git. Afterwards we'll look at how you can create your own patches, using git diff
and git format-patch
, in order to contribute code back to Drupal or any of the module's on Drupal.org. You can see a full Git workflow using GitHub in the lesson Git Workflow: Putting It All Together.
Additional resources
Git Best Practices: Upgrading the Patch Process article
Applying a patch in a feature branch
In this tutorial, Joe walks you through a typical Git workflow. We start with cloning a repository, creating a branch, and getting some work done. Then we go ahead and commit our work, merge it into the master branch, and push our changes back up to the remote repository.
We've now learned about all sorts of commands in git and the flags that accompany those commands. We've also seen that some of those commands can get to be a bit long and are used quite often. In this lesson we're going to take a look at how to create command aliases in our .gitconfig file so that we can have a shorthand for accessing some of these more esoteric commands. We'll also take a quick tour of Joe's personal .gitconfig file that he uses in his day-to-day work.
What is version control? Why should we be using it? Where do we even start? Managing your code is very important, both to make sure you don't accidentally lose a lot of work, but to also make it clear who is working on what and be able to track those changes over time. There is a big world of version control systems and this Do it with Drupal session with Blake Hall will explain the general concepts and best practices around using version control, as well as provide some demonstrations of one of the most popular ones being used today, Git.
Additional resources
This video shows you how to create your own custom shortcuts for various commands. We'll look at some common aliases and see how to add them to our command line environment. This is super handy for commands that you type in all the time and don't want to go through the tedium of typing the whole thing out every time. For example, we show how to automatically go to a particular directory with just one word (e.g. type "clients" and go to the /Users/add1sun/lullabot/clients directory immediately).
This video looks at the basics of working with MySQL from the command line. We get into the mysql environment and look at databases, tables and fields. We cover creating and deleting databases, creating a user, and querying within a particular database.
Note: In some places the command line prompt is cut-off. The YouTube version of this video doesn't have the cut-off problem. We are working on getting this fixed, but in the meantime, check out the YouTube version instead.
Command Line Basics 13: Using MySQL from Command Line (youtube.com)
This is an introduction to the Tail command, available on Unix/Linux systems. Tail has many applications, but this video concentrates on its basic usage and useful options, as they pertain to Drupal developers.
You'll learn how to take a quick peek at recent log messages from a single log file, how to do the same thing with multiple logs, as well as watching log files in real time! We'll finish up with a practical application, to see why this is useful.
Commands used in this video:
To view the documentation (or manual) for the tail command:
man tail
To show the last 20 lines of the webserver's access log file:
tail /var/log/apache2/access.log
To show the last 20 lines of the webserver's error log file:
tail /var/log/apache2/error.log
To show the last 20 lines of the webserver's error log file and continue to print new lines added to the file:
tail -f /var/log/apache2/access.log
Object-Oriented PHP Part 2
CoursePHP Service Classes
FreeIn this course, we're going to continue on from the Introduction to Object-Oriented PHP series. We're working on the same spaceship project: it has ships, you choose them, then they engage in epic battle!
In an editor, far far away, you'll see a simple application that runs this: index.php is the homepage and battle.php does the magic and shows the results. In the first course, we created a single class called Ship
, which describes all its properties—it's like a container for one ship's details. In this tutorial we're going to replace our flat functions and create a BattleManager
service class to provide the methods we'll need to do that.
This course introduces important concepts in object-oriented PHP. It is authored and produced by our partners at KnpUniversity (now SymfonyCasts). In this PHP course, you'll be building a PHP app using PHP and refactoring the code, step-by-step, using concepts in OO-PHP such as classes, methods, access control, type hinting, and constructors. You'll learn how to have one object interact with another and by the end of this project, your PHP app will be sporting some shiny new object-oriented PHP.
In this lesson, Leanna introduces you to the project and shows you how to get it up and running. So, look for the Course code download link below and we'll walk you through the process of getting the app up and running on your computer using the built-in PHP server. As long as you have PHP installed on your computer and a code or text editor, you should be able to complete the lessons in this series. (A full stack web server (i.e. Apache/MySQL/PHP) is not required, only PHP.) Follow along by running commands from the start
directory.
Additional resources
This PHP tutorial covers the basics of classes and objects. You'll learn how to set up a class and then what a class is and what objects are like. By the end of this tutorial you should be able to create a class, an object, create a property, and set the value of a property inside a class.
Additional resources
In this PHP tutorial, you'll learn about methods — functions that live inside objects. You'll also learn how to access properties inside methods using the $this
pseudo-variable.
Additional resources
In this PHP tutorial, you'll get more practice working with methods. Along with adding some functionality to a method using PHP's sprintf()
function to format a string, you'll use the $this
pseudo-variable, and learn how to add and use arguments with methods.
Additional resources
In this PHP tutorial you'll learn how to work with multiple object instances of the same class that have different data and function independently.
Additional resources
In this PHP tutorial, you'll learn how to create a method that will enable multiple objects to interact with each other.
Additional resources
In this PHP tutorial, you'll learn how to add a specially-formatted comment to your method that will enable additional autocomplete functionality in IDEs such as PHPStorm.
Additional resources
In this PHP tutorial, you'll learn how to refactor the practice code in play.php into the Ship class. You'll get more practice working inside of a class and with objects.
Additional resources
In this PHP tutorial, you'll learn about to change the visibility of properties to private
and how this affects how these properties can be accessed. You'll change the public properties to private and then add "getter" and "setter" methods to the class to enable controlled access of the values of these private properties.
Note: the word "hooks" in this video does not refer to hooks in Drupal's API.
Note: PHP does provide magic methods for getting and setting which are explained in this tutorial: Magic Methods: __toString(), __get, __set.