When installing composer dependencies those dependencies are downloaded and stored in the 'vendor' directory. There are options available to install this into a different location than the composer.json file, but it's generally found in the same directory.
The vendor directory contains quite a bit of code, which is especially the case if your project contains quite a lot of dependencies. More often than not though, this directory will not contain any code that you have actually written. It will contain the necessary third party libraries that allow your code to work correctly.
A common technique when creating graphics or visual representations of data is to map a value between two scales. This is useful when working on a set of values and you need to map them to a different set of values in order to show them on a graph.
The maths involved here is essentially figuring out the relationship between the value (v) in our initial scale (x, y) and multiplying this by the maximum range of the second scale (a, b).
The Splat Operator In PHP
The PHP splat operator (...) has been available in PHP since version 5.6. When it was introduced I made note of it but have never really used it, so I thought it might be interesting to explore it a little.
Internally, the ellipsis operator in PHP is called T_ELLIPSIS, although I have heard a few different names for the operator in the past. This includes names like:
philipnorton42Wed, 08/05/2020 - 13:37
Using PDO To Create A Data Access Object
A Data Access Object (DAO) is a way of taking data out of a database or API and present it in a unified way across your application. As a design pattern this has uses in standardising how a particular bit of data is passed around, without having to resort to using arrays to accomplish the same job.
philipnorton42Tue, 08/04/2020 - 12:03
PHP:CSI Get Price In Pence
I was looking at some malfunctioning code the other day where the price was pulled out of one API service and sent to another API. The problem stemmed from the fact that the value coming out of the first API was as a string and the second API required the price in pence as an integer.
The difference in formats here meant that the number had to be converted from one format to another. During this process it was found that the value was sometimes out by a single pence.
philipnorton42Fri, 07/17/2020 - 17:51
Wrap Around Increments
Something I've been writing long hand for a number of years is wrap around increments. This is essentially adding to a value that has an upper limit, and wrapping back to 0 when that max value is reached.
This can be done with an if statement.
philipnorton42Sun, 06/21/2020 - 20:48
Spelling Words With The Elements
The other day I was tasked with creating the weekly quiz for my family. I decided it would be good to do a section that would consist of 10 words that were spelled using symbols of the chemical elements. The questions would be presented as a list of element names, like this.
This breaks down to the element symbols in the following way.
philipnorton42Sat, 06/06/2020 - 17:20
Using Deployer To Deploy Drupal 8 Sites
Deployer is a PHP based deployment tool that I have been using very successfully for a number of months now. It comes with a number of different recipes to deploy a variety of PHP based applications, including Laravel, Symfony, Yii, and Drupal.
I first found Deployer when looking for a deployment package that suited my needs. Phing had been my tool of choice for a number of years, but it had proved problematic trying to debug the XML syntax when things needed tweaking. As I was deploying PHP applications it made sense to me to use a PHP based system to do the deployment. I looked at tools like Capistrano, but as I wasn't that familiar with Ruby I was worried that I wouldn't be able to debug mistakes or customise the deployment process easily.
philipnorton42Tue, 04/28/2020 - 19:04
Overwriting Command Line Output With PHP
The other day I was trying to print some output to the command line and then overwrite the output afterwards. It turns out that there are a couple of ways to do this so I thought I would detail a few of them here.
By far the simplest way of doing this is to run the "clear" command, which we can run via the system() function in PHP. This will clear the output of the command line ready for you to print out whatever you need. The downside to this is that the entire terminal window is cleared. Another downside is that once the output is complete scrolling up will reveal the output that was cleared out.
philipnorton42Sun, 04/12/2020 - 21:49
Conway's Game Of Life In PHP
I was saddened to hear of the passing of the Mathematician John Horton Conway today so I decided to put together a post on his 'game of life' simulator.
This game of life, more commonly called Conway's game of life, was devised by John Conway in 1970 and is a way of modelling very simple cell population dynamics. The game takes place on a two dimensional board containing a grid of orthogonal cells. The game is technically a zero player game in that the initial setup of the game dictates the eventual evolution of the board.