The PHP Project Guide (2014)
2. Starting a project
When I talk about a project, I basically mean something you’re aiming to build with a specific purpose that will be used by people to achieve something, or will be used to increase or create value for a specific purpose. A project doesn’t have to be a commercial, it can simply be something you’d like to do to learn more about a language or could be something personal that will help you manage something better.
2.1 Project examples
Let’s look at some reasons you may be starting a project and what you’ll need to achieve the end result. This often helps visualise how you’d start your own project.
· A system that logs and records items. For example, you may play golf and feel like a system to record when you’ve played, your score and any notes. You’d need an interface, fields to enter specifics about your game and a database to hold this information. You’d then need to query the database to retrieve aggregates like the total rounds played in a chosen date range.
· A chat system. You need a system to chat in real-time within the browser to support workers and clients within a workplace. You could use one of the many already available online but want something simple. You’d need a basic interface, the ability for clients to enter some basic details about themselves to use the chat and then the ability for a client to post text and see the chat manuscript as it’s happening. You’ll also need pretty much the same functionality for whoever is talking to clients or workers.
· A shop. If you’re selling items online, you might want to build a shop to allow adding to basket, registration and checking out. You’d need to build a secure authentication system to allow users to register and you then need to build in functionality to add items to a basket within that session. Checking out could then be handled by either PayPal cart checkout, PayPal Payments Advanced for credit card acceptance or another credit card processing API. These are usually well documented and support PHP.
You’ll notice a common theme amongst the examples above, whether or not they apply to you. The common theme is that they all involve database interaction and storing data. There are a few ways you can store data for later retrieval to display to a user, but there are thousands of different websites that can be built with a frontend, PHP and a database. For this reason, you’ll find we cover quite a lot of database theory (not boring theory about the inner workings of databases, but how to think logically about what is required from your database). We’ll also look at security as we’re working with a dynamic language and you’ll often require user input of some kind. There are ways you can help yourself too, by using a framework, so we’ll be looking into these and considerations that surround choosing a framework.
2.2 What you don’t need
There are a variety of things you absolutely don’t need when starting a project for the reason they cost you time and money and take the focus away from the important thing - the end product.
· Business cards
· Expensive software
· Expensive hardware
· An expensive, powerful webserver
Of course, if you’re starting a design company, you may need something like Photoshop. But, if you just need a logo for your website, there’s no need to go out and buy Photoshop for this reason. Use something free like GIMP, instead.
Expensive hardware is also unnecessary as you can build a website on the most basic of hardware. If your computer isn’t the greatest, there’s no need to worry. Likewise, you won’t need a powerful server to host your project on until the demand is significant enough to do so. During your development and launch phase, there is no need to cater for this demand unless you’ve spent thousands on advertising that’ll invoke a large number of people visiting your website.
Business cards are useful sometimes, but it’s unlikely you’ll need them in the initial stages of your project. If you meet someone who you may potentially work with or would like to test out your website, you don’t need to hand them a business card - just give them your contact details as you would anyone else.
In today’s world, there isn’t a lot of need to advertise unless you need to reach people on an epic scale or if you have a large budget and want to increase brand awareness. If you create a good project and provide excellent service, people will talk about your product and therefore eliminate the need for advertising. Carefully incorporating social networking aspects into your product can also lead to your website becoming popular through social media. Please be careful though, adding a ‘like’ button at the top of every page or article is less valuable than it may seem.
And lastly, employing staff is almost always unnecessary from the outset. If you’re working with someone and splitting the company 50/50, this isn’t staff. If you hire someone to answer customer queries by email when you don’t need to, this is unnecessary. Try and deal with things like that first before wasting money on hiring someone for something that isn’t a problem yet.
2.3 Taking the first steps
The first step to a successful product is to plan it out and get stuff done as quickly as possible. This means cutting out the time you take to carefully design wireframes and hire designers to put together a great design for you. So what if you end up with a working product that doesn’t look quite right? You can perfect that after you know people want to use it.
It’s a really good idea to start planning the functionality and start building as soon as you can, learning along the way. If your goal is to learn, these rules still apply. Building a really great looking template isn’t going to help you learn PHP.
I often start building parts of a website in isolation. For example, if you need a currency converter on your website, create a blank file, research a currency conversion or finance API and start building something that works. It won’t disappear, so will always be there for when you need to come back to it. It’s simply another thing ticked off the list of what you need to do.
“Fail to plan, plan to fail” is a saying you may have heard. It’s partly true, but can be taken in the wrong way. Planning isn’t writing up long documents, holding loads of meetings or sitting by yourself writing reams of notes on what you need to do. Planning can be as simple as a non-prioritised to-do list. What bits do you need to build to make this website work? Short, simple tasks for the day will help you progress quickly without getting bogged down by massive amounts of information or instructions. If you’re building the project initially for yourself or you’re part of a very small team building an in-house product, minor details aren’t likely to matter anyway, you can simply tweak them later after you’d received feedback.
But what if I just want to learn?
If you are still very new to PHP, your primary goal is probably to learn. Change that primary goal into building a product that works. The by-product of this will automatically be that you learn about PHP and the way it works since you’re applying yourself to a real-world situation. Learning the theory of variables, loops and functions is all good, but how are you going to use them?
My first ever PHP project was building an application that counted daily intake of nutrition in food. At the time I actually believed it would be a useful product and built an interface where users could register, enter information about what they’d eaten, select items from a list that they’d previously entered, modify that information if required and see daily intake statistics and charts, as well as look back at previous days. This took me months and months to build, something that I could now realistically be built properly in a couple of weeks. Being able to develop something quickly comes with experience, not just knowledge.
A lot of people will get frustrated when they’re building something and can’t quite achieve the result they’re after - but this is a good thing. It really helps when you struggle, because once you finally grasp something, it’s unlikely you’ll forget it.
2.4 How long should a project take?
As we saw in my example above, it took me months to build my first real project. I no longer have the source code but the knowledge I gained from it was valuable.
There is no specific time you can give to learning anything, it’s the time you put into it that counts. More importantly, it’s what you do with that time. I’d highly recommend anyone learning PHP, or wanting to advance what they know already, to build a project. The reason this book is entitled “The PHP Project Guide” is because it’ll guide you through what you need to know to start and work on a project, hence stimulating the learning process by building a useful product.
Ask any seasoned developer how long it took them to grasp PHP and they probably won’t know exactly, and probably because they learned while working on projects and were unaware of the time it took them to grasp the language.
Let’s jump in!