Down the Rabbit Hole

Tina4 is a PHP Stack or what is commonly known as a framework. Tina4 claims not to be a framework (This is not a 4ramework!) Down the rabbit hole represents a journey with using Tina4 from simple concepts to increasingly more complex stuff. Each step down the rabbit hole builds on the previous step and hi-lights concepts that you can use to build your own systems. _

Let's jump into the hole

Whether you work on Windows, Linux or Mac, you need to use a terminal at some point, you also need a reliable editor, the first step down the rabbit hole is to choose your terminal and IDE. You also need some basic tools; h every software engineer should have on their computer. Most importantly you need to have PHP installed on your OS unless you choose to use the docker environment.

Lets check if you are up and running, open a terminal or power shell and run the following commands

Test for PHP

php -v

And it's result:

PHP 7.4.20 (cli) (built: Jun  3 2021 19:10:14) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.20, Copyright (c), by Zend Technologies

Test for Composer

composer -V

And it's result:

Composer version 1.10.13 2020-09-09 11:46:34

Test for OpenSSL

openssl version

And it's result:

  LibreSSL 2.8.3

Test for Git

git --version

And it's result:

  git version 2.32.0

The first jump - what did we learn

Often getting up and running and coding can be more difficult than the actual coding. Deploying your application after you have coded it can also be more challenging than the work that you did to write the application.

  • We should have the basics now to start developing in PHP
  • We should have version control running with Git

If any of the tests above fail, you should spend some time to see about resolving the issues. The most important is to have your PHP running. _

One meter down

I'm assuming you have never seen PHP code before , I am hopeful if you have some concept of what a website is and what is HTML. All you need to know right now is that websites are TEXT! That's it, all a web server does is send text to the browser which interprets it into the pretty websites you see every day. As a programmer you need to know how to put that text in the right sequence so it makes it look great.

Our first PHP program

Before we get to far down this hole, lets make sure you're organised. We recommend making a folder on the root of one of your home folder called projects. Inside projects you can create other folders as a way to track your progress. In your projects folder make a folder called tina4example1 and open the folder as a project in your IDE or editor.

Example 1

Add this code to a file called test.php

echo "This is just text!";

Now you need to run the code to see what it does. Open up a terminal in the example folder and run the following:

php test.php

You should get an output similar to the following:

Microsoft Windows [Version 10.0.19043.1083]
(c) Microsoft Corporation. All rights reserved.
D:\projects\tina4examples\example1>php test.php
This is just text!

Now we would like to get it running as a website and we can do it very easily using the built in webservice of PHP!

php -S localhost:8080 test.php

As you can see you should get a link which you can click on and view in your browser.

D:\projects\tina4examples\example1>php -S localhost:8080 test.php
[Sat Jul 10 11:19:38 2021] PHP 7.4.13 Development Server (http://localhost:8080) started

You have just created a website. Feel free to edit the test.php file and add other echo statements to see what happens, below are some examples

echo "This is just text!";

echo "<h1>A header tag </h1>";

//This is how you make comments, notice it won't appear when you refresh your browser
echo "<hr>";

echo "<button onclick=\"alert('Made you click!')\">Click Me</button>";

One meter down - what did we learn

As you can see a website is just text, if you want to become good at making websites a command of HTML and CSS is essential. Before we carry on further you may want to go do some reading on HTML. There aren't that many tags and you can play with them in the test program.

Going deeper

Powered by ComboStrap