Website News

Conservation and PHP

Today I have struggled with PHP. I struggled because I want to recreate the same table using loops with PHP as I did formatting with HTML. If I wasn’t up for a challenge I would let PHP loops format it according the default and I’d be done. In the end I did get the table to display as I wanted but not using for loops. I created a table page, laid it out using the data file I’ve been using for this section, and then using include to add that content where I wanted it to be on the page.

A Rainy Day Without Walking

Today the weather app said that it would start raining at 1500 so I didn’t go out for a walk. In the end the rain started at around 1630 or even later. I could have gone for a walk and I could have come back dry or almost dry.

For years I went for walks almost everyday, whatever the weather conditions. I grew tired of the habit. I have had this habit for five years or more, three of which have been during the pandemic.

A Shift to PHP

PHP has been around for decades but I learned of a way to experiment with it easily recently so that is why I am playing with it now. The main page is php as is my first “blog” although it was part of a column for the student newspaper, that I converted to an electronic format and published frequently.

I tried to keep Surfing the World Wide Waves looking as it had back in the day. The aim is to practice with PHP and get some things to become automatic. I include one php file with the data, and a second for the footer. I use a loop to populate each blog post.

Experimenting with PHP

I have been following courses for three years now. Within the last week or two I decided to start experimenting with PHP using my website as a guinea pig. I have already converted a few pages to PHP. Some of them use for each loops and others use the include functionality. My aim is to practice the skills that I have studied, within a production environment.

Some of the tasks are repetitive. This isn’t a bad thing. It builds habit and understanding. By doing something frequently enough the pattern gets burned into my subconscious. When that’s done I will spot errors automatically, and if I get an error message I will know what it means.

PHP from the Command Line

Recently I learned that PHP has a built in server. You don’t need xampp or any of the other solutions. All you need is terminal open, have the current directory be the one with the PHP files you want to serve and type: “php -S localhost:8000”

This might sound obvious to some but it took years for me to come across this. When you have to install xampp or other solutions you need to dedicate HD space, run the servers and more.

On Whether I Prefer Vanilla JavaScript or Frameworks?

Today someone on twitter asked this question, and rather than be reply: 320 of 10,000, I chose to write a blog post about it. The TLDR answer is Vanilla JS because if you learn how it works without the help of a framework you understand the language. This doesn’t mean that I don’t have an interest in learning to take full advantage of frameworks.

As I listen to JavaScript Jabber one thing is clear. Whereas if we listen to courses and twitter discussions we are tricked into thinking that we should either use React or Angular we see, through JavaScript Jabber that frameworks are as diverse as they are flexible. One app will be excellent for one type of task and another will be awesome for something else. If you spend time learning Vanilla JavaScript, and then you learn about the diverse choice of frameworks then you can either write concise and effective code that does what you need with little to no bloat.

On The Desire To Change Career

If I had been smart I would have changed career path around 2006-2007 when I was in London surrounded by entrepreneurs and web developers, rather than now during a pandemic. Normally I struggle to find new contracts because of two things. The first is that for camera and editing work there are very few opportunities per year, and the opportunities that do arise have hundreds, if not thousands of candidates so the probability of success is low. The other issue is that because there are few jobs, if you fail you may have to wait months for an opportunity to appear.

Switching From MySQL to MariaDB with Infomaniak

Today I tried Switching from MySQL to MariaDB with Infomaniak as a webhost. This morning they sent an e-mail to say that we could switch from MySQL to MariaDB automatically so I tried. For the test I:

  • downloaded a new install of wordpress to my local machine and put it in the MAMP htdocs folder under mariadb.
  • I installed MariaDB on port 3310.
  • Using the command line I created a wordpress database.
  • I configured WordPress. Within seconds the website was up and running.
  • When I saw that the interface was that the same and that I had to make no changes I went ahead with Infomaniak.
  • Of course I backed up the MySQL server data, just in case.

Within a matter of minutes of telling Infomaniak to switch from MySQL to MariaDB the migration was finished and the website was up and running again. It was quick and painless. If something did go wrong I could easily step back but I also ensured that the user interface for MariaDB and MySQL were the same. When you’re coding websites from scratch some databases require different lines of code to function. That was my concern, and that’s why I decided to experiment with a small scale trial on my own machine.

WordPress Child Themes

For a while, I have been thinking about creating my own WordPress themes, but I didn’t know where to start or how many hours it would take. I always assumed that it would take many hours and that I would have to create templates, style sheets and more for a number of pages. In reality, you need an index.php page and a stylesheet. Anything else is a bonus.

A shortcut is to find a theme that you like and to see which fields you want to modify and just modify that behaviour. Choosing to use another font requires one or two lines of code. With minimal effort, you can personalise a theme.

Learning To Code By Building CMSs

It’s easy to use Facebook or other CMS every day without thinking about how the code works. This summer I have coded two CMS using Linkedin Learning. One of these CMS was running with PHP and MySQL and the other was running with Ruby On Rails and MySQL.

The PHP CMS

In the process I learned how to install MySQL, how to get MySQL and PHP to talk to each other. How to organise files between private and public folders on a web server and more. Getting MySQL to talk with the web server was a challenge that took a few days to get right.