Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

Archive for September, 2016

Running terminal commands with PHP

Tuesday, September 27th, 2016 by Servage
terminalSometimes you may find yourself in a situation where you want to run more than just PHP code. Perhaps PHP does not have a built-in function for what you want to do or you want to run some custom commands, such as executing an external program. There are multiple ways to achieve this, and we will learn how to do it in two different ways. The usual way: exec() and shell_exec() These two functions are likely the ones that come to your mind first when thinking about a way to execute a terminal command. Both of there are basic PHP functions, and they are very similar to each other. The biggest difference between ...

Preprocessing HTML using pug

Friday, September 23rd, 2016 by Servage
pug-templatePug is a templating engine that aims to make writing HTML files faster and easier. In fact, Pug could be said to be an HTML preprocessor. You have probably heard or used CSS preprocessors like Sass or Less. Pug is very similar for HTML; you write it using a special syntax and compile it into plain HTML. Let’s have a look at how easy using Pug is and why you should consider using it. In this article we will not set up a Pug development environment, but instead we will talk about what Pug is and in what situations it can be a good addition to your technology stack. What is Pug? If you ...

Tricks in PhpStorm to save your development time

Monday, September 19th, 2016 by Servage
phpstormPhpStorm is one of the most popular PHP integrated development environments (IDEs) in 2016. It has a huge amount of features and even experienced developers regularly come across new features they haven’t known before. Next we are going through some handy tools and shortcuts that are built into PhpStorm but may be difficult to find out on your own. PhpStorm is full of useful keyboard shortcuts. Here are a few that you will surely find useful. Keep in mind that these may be slightly different for you depending on your operating system and PhpStorm version, but these are the default ones for Windows. Ctrl + Shift + N: Find a file in your ...

Handling JSON with PHP

Monday, September 12th, 2016 by Servage
jsonJSON is a data serialization format that has become the de-facto standard for transmitting data between applications. It is more and more often preferred over its competitor XML thanks to being lightweight, human-readable and widely supported. JSON is also supported by PHP, so let’s see how PHP can be used to read and write JSON. Creating a JSON Object PHP has two functions that are often used to deal with JSON: json_encode() and json_decode(). These functions have been built in to PHP since 5.2.0. First, let’s see how we can use json_encode to create a new JSON object. Before we get started, it’s good to know what kind of data can be turned ...

Gitflow workflow explained

Tuesday, September 6th, 2016 by Servage
gitflowGit or an equivalent version control system (VCS) is an essential tool in web development. No matter what VCS you use, it is good to know the basics of Git since it is by far the most popular choice these days. Git is a versatile tool and there are multiple ways, also called workflows, to use it. One popular workflow is the Gitflow workflow, which we will cover in this article. Branches in Gitflow Many Git workflows use one branch to track the history of a project. Most often this is the master branch. In Gitflow there are two branches for this purpose: master and develop. The develop branch contains the latest features ...

Introduction to HTML5 canvas element

Sunday, September 4th, 2016 by Servage
html5-canvasThe <canvas> element is probably the greatest addition to HTML5. This new element can be used to create anything from a single-color box to complex shapes and charts. We will take a look at how to build some simple shapes with the <canvas> element and learn what can be achieved with more advanced use of the element. What is an HTML5 canvas? In simple terms, a canvas is a <div> inside which you can render graphics. Those graphics can be simple shapes such as circles and boxes, or more complex graphics like charts and even animations. A canvas can be created with the <canvas> tag. This might come as a surprise, but drawing to ...