Hire PHP Coders

Recent Posts

How To Check Laptop Battery Using Upower


Checking your laptop battery from the command line is rather easy using the upower command. This article is an introduction to the Linux upower command and an example from my Linux laptop which is used as a PHP Programming test server.

Background

I have 2 laptops that I use as test servers. They were cheap so I bought one for my wife and one for me. We never really used them so I converted them into PHP programming test servers.

Originally I took the batteries out and stored them away from the computers because we were not using them as portal devices.

Theses computers are probably 4 years old. One battery is dead. Surprisingly the other battery appears to be in like new condition. It has been about 8 months since I changed the good battery and today it is showing 35% charged. It has been setting in my desk drawer.

The local Linux community tells me to keep my battery charged between 30 and 70 percent. They say anything below 30% will add extra wear to the battery as will any charge over 70%.

Currently I do not need the battery, however I may want to load something Like Mint Linux on this computer and use it as a mobile Linux computer. Therefore I would like to keep the battery in good condition and that is why I periodically charge the battery.

Monitoring Laptop Battery Charge

My laptop is running Ubuntu 16.04lts and I had to add the upower package. From the command line it is rather easy – two steps.

sudo apt-get update
sudo apt-get install upower

This morning I put the good battery into my laptop and ran “upower -i” /org/freedesktop/Upower/devices/battery_BAT0 from the command line. Here is the output:

Notice my battery is at 37% change. Amazing!! I was expecting the battery to be dead.

To determine just the state of the battery, time to fully charge, and the percentage of charge, run the following command on the command line.

upower -i $(upower -e | grep BAT) | grep –color=never -E “state|to\ full|to\ empty|percentage”

Here is the output from my laptop:

Since I am only charging my battery to 70%, I expect a much shorter charge time than what a full charge would take. It show it would take 1.7 hours for to fully charge.

Upower Man Page

You can learn more by running “man upower” on the Linux command line. The man page does not give much information, however for my needs, I do not need anything more than is documented in this article.

Conclusion

You may need to install the upower package which is very simple. I provide the command necessary to install the package from the command line on Debian and it’s derivative Linux distributions, such as Ubuntu 16.04lts.

If you need a simple way to monitor your laptop battery from the command line upower may be all you need.

What is CodeIgniter and How Does it Work


This article explains what the CodeIgniter framework is and gives insight as to how CodeIgniter works. 

CodeIgniter is Object Oriented, Model-View-Controller, a Rapid Application Development framework for PHP, that has a small footprint, is blazing fast, has a short learning curve, and is easy to install. CodeIgniter does this by providing commonly needed functionality, helpers, and libraries.

What is CodeIgniter

CodeIgniter was created by Rick Ellis the owner of Ellis Labs. The first release was on February 28, 2006. CodeIgniter was wildly successful and very popular within the PHP community. 

CodeIgniter has a lot going for itself.

Small Footprint

Version 3.1.11 is only 16 megabytes in size. That is small. In the early days, CodeIgniter was less than 4 megabytes.

Version 2.2.6 is about 4K compressed and is 5.1 megabytes uncompressed.

Blazing Fast

Most report CodeIgniter is lightning fast. It is compatible with shared hosting which it’s pears cannot say. The CodeIgniter framework puts little stress on the hosting server.

Excellent Documentation

The manual covers, in detail, every aspect of how to use CodeIgniter to build websites and web applications. All features and functionality are well documented.

The documentation can be viewed online at: Codeigniter 3 User Guide.

It is worth noting that in the upper right corner of the page there are three lines next to the search box. Clicking the three lines changes the layout to the old-style layout which is much more helpful. 

CodeIgniter Manual Layout Toggle

Once clicked, a tab will appear in the upper right area named “Table of Contents”. If clicked, it will display a full menu that will give you access to every bit of the documentation.

CodeIgniter Manual Menu Drop down Image

Easy to Use

Ease of use is one of CodeIgniter’s hallmarks. It was created early before PHP added several features that are complicated. CodeIgniter 3 is simpler than CodeIgniter 4. CodeIgniter 4 embraces the PHP features that make it more complicated. For the one-man-band, those features are not necessary.

Easy to Install

To install CodeIgniter all that is required is to download the zip file and upload it to your server and unzip it. And point your web browser to the instilled Codeigniter and it should show you the welcome page.

Object-Oriented

Even though CodeIgniter is Object-Oriented, an inexperienced programmer will probably not notice since everything is well structured and well documented.

Model-View-Controller

As you probably already know CodeIgniter is Model-View-Controller. This design pattern is widely used and respected. It helps structure one’s code and makes it easier for multiple developers to work on the same project. 

What is a Controller – This is the boss of the other two. It is the brain. This is where most of the programming logic is placed. 

What is a View – Is the display layer. This is where the HTML, Cascading Style Sheets (CSS), JavaScript, AJAX, and content come together to create what shows in your browser. 

What is a Model – This is where all the database functionality lives. These functions are called by the controller so the data can be processed and then sent to the view.

License

The current owner, British Columbia Institute of Technology, uses the MIT License. Here is what it says:

Copyright (c) 2014 – 2019, British Columbia Institute of Technology

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The Online License

Versions

Currently, there is two versions of CodeIgniter. Version 3 and 4.

Some of the differences are:

  • CodeIgniter 4 is not backward compatible.
  • Version 4 has added support for Namespaces.
  • Autoloading support has been added to version 4

Life Cycle

According to the Codeigniter forums, Codeigniter 3 will be supported for about 2 more years. 

The repository will live on. The only real issue with using Codeigniter 3 after community support ends is PHP version upgrades and security issues will go unaddressed.

Loosely Coupled

CodeIgniter is referred to as loosely coupled because only a controller is required. The model and view are not required to make a working website. Though, this is not the default configuration. 

CodeIgniter Release History

VERSIONRELEASE DATEEND of LIFE
1February 28, 2006Unknown End of Life
2January 2011October 2015
3October 2015Currently Supported
4February 24, 2020Currently Supported

Helpers

There is about 21 helpers. Each is a set of functions that can be plugged into your code as you build your application. Helpers help the developer accomplish tasks. To get a feel for what a helper is let us look at a couple of helpers that are routinely used.

URL Helper Example

The URL helper is a set of functions that make working with URLs easier. You can read the on-line URL Helper documentation for more information.

For example, to convert the title of an article into a URL string, the helper function url_title($title) could be used. Here is some sample code:

$title = "Why I Like Ice Cream";
$url_title = url_title($title) 

$url_title will contain the string “why-i-like-ice-cream”. Which can be used to create a complete URL like example.com/why-i-like-ice-cream.

The whole idea is the helpers help the developer to write less code and spend less time doing so. This is the rapid application development feature mentioned elsewhere. 

Email Helper Example

The email helper makes it easier for the developer to add email functionality to his or her application.

For example, to validate an email the developer can use the valid_email() helper function.

Here is an example:

$is_email_valid = false;
if (valid_email('someemailaddress@example.com'))
{
        $is_email_valid = true;
}

You can read more about the email helper by reading the on-line Email Helper documentation.

[] 

Libraries

There are about 30 libraries in CodeIgniter 3. Libraries help the developer complete larger tasks such as sending an email. Sending email takes a lot more effort than checking the validity of an email address such as what we previously performed.

The email library is a class that provides comprehensive functionality for sending emails. A glance at the on-line Email Class (library) might be surprising given all the options and setting that are needed to send an email. 

What is CodeIgniter Used for?

Codeigniter is a PHP framework that was created as a PHP rapid application development tool. In the early days, Codeigniter was used to create all sorts of websites. CodeIgniter is still capable of creating any type of website you can think of, however, today it is mostly used to create web applications. 

The Installation Process

If you are familiar with the Linux utility wget you can download the zipped file directly to your server and unzip it.

It is that simple.

It is not necessary to have access to the server command line. 

Installation only takes a few minutes and is just a few steps.

With wget

  1. Use wget to download the CodeIgniter zip file into the hosting root directory.
  2. Unzip the source file.
  3. You may need to rename or remove the leading CodeIgniter directory.
  4. Point your browser to your CodeIgniter install and you should see the welcome page.

Without wget

  1. Download the CodeIgniter source file onto your local computer.
  2. Unzip the source file locally.
  3. Upload the files to your server using FTP. Make sure not to include the CodeIgniter leading or root directory when uploading.
  4. Point your browser to your CodeIgniter install and you should see the welcome page.

Verify it is Working

To verify your installation is working, all you need to do is point your browser to the server where you installed CodeIgniter. 

If it is installed correctly you should see the welcome page.

Image of the Codeigniter Default Welcome Page

This is a page that comes with CodeIgniter. It gives you the path to the view and the controller. Notice the last line contains a link to the User Guide. This is a local copy. You may want to bookmark this link so you will always have access to the documentation off-line.

How Does Codeigniter work

As you have read in this article, CodeIgniter is easy to install, is blazing fast, easy to learn, is well documented, and has a short learning curve. Add to that it is Model-View-Controller.

Codeigniter is a rapid application development tool for building PHP web applications. These applications can take the form of a content management system (CMS) to an interactive web application.

Because CodeIgniter comes with so many of the needed components for building web applications, in so many ways, it is plug and play. This keeps the developer from having to recreate the wheel every time they want to build a web application.

Let start by looking at the file system. Once installed you should see a file system that looks like this:

  • /application
  • /composer.json
  • /contributing.md
  • /index.php
  • /license.txt
  • /readme.rst
  • /system
  • /user_guide

To learn CodeIgniter it would be worthwhile looking through all the directories and open the files and read through them. Do not worry if some of it or even a large portion is hard to understand. It will be a worthwhile excise that will help you as you become a CodeIgniter developer. 

In this article, we will limit our discussion to 4 directories and how they work. Knowing what we will be covering will place you well on your way to becoming a CodeIgniter developer.

As a starting point, let’s look at the welcome controller, welcome view, and the routes configuration that ships with CodeIgniter 3.

  • The welcome controller is located in: application/controllers/Welcome.php
  • You can find the view at: application/views/welcome_message.php
  • And the routes files is located at application/config/routes.php

The default URL mapping is example.com/controller/function/argument. In the case of the URL for the welcome message, it is example.com/index.php/welcome/index. 

Controller

If we look in the controller we see several lines:

1) defined(‘BASEPATH’) OR exit(‘No direct script access allowed’); – this line verifies CodeIgniter is running. If not it sends a message to the browser and stops processing. This is a security measure so the only entry point is through the index.php file located in the root directory. This will keep the bad hackers from accessing your code in ways it was not intended.

2) class Welcome extends CI_Controller – Notice the controller class name is Welcome and it extends CI_Controller. This means it inherits everything in the CI_Controller class.

3) public function index()

{
   $this->load->view('welcome_message');
}

The index function is the default function in the controller. Remember the URL mapping is /controller/function/argument. If no function is listed, the default is the function named index.

In the case of the welcome URL it is /index.php/welcome/. You can drop welcome from the URL leaving it as example.com/index.php.

Two things are taking place. One is the default controller that is defined in the routes.php file is being processed and the default function in the controller is used to complete the process so the welcome page can be displayed.

The line $this->load->view(‘welcome_message’); Tells CodeIgniter to load the view file named welcome_message’) and display it.

View

The view can be located at: application/views/welcome_message.php. A quick look inside shows it contains HTML, Cascading Style Sheets, and a minor amount of PHP code. 

Data can be transferred to the view file and the view file can use PHP to display this data. It is possible to process data in a view, however, all the processing should take place in the controller and model.

Basically, a view is web content or what is known as the visual layer.

Model

In this case, there is no database in use so there is no model. We will cover the model later in the article.

Router

The routes file is located at: /application/config/routes.php. There is only one line in the file that we need to evaluate here. That line is: $route[‘default_controller’] = ‘welcome’;

What this line tells CodeIgniters is the default controller is the welcome controller that is listed above. That is why you can go to the website URL such as example.com/index.php and see the welcome message. 

Removing index.php from the URL

To remove the index.php from the URL (example.com/index.php) refer to the manual page at: CodeIgniter URLs and then scroll down to “Removing the index.php file”.

If you are using shared hosting it is probably already configured to remove the index.php from the URL. If it is not configured you will get a blank screen or an error message.

If an error occurs or you get a blank screen contact your hosting provider for help. 

Create a Model for the Welcome Application

Create a model class named “people_model” in the application/models/ directory. Name the file People_model.php. It is a good idea to create a model for each table. This will keep the models organized and by naming the model the same name as the table it makes it easy to understand what goes with what model and it also becomes self-documenting. 

The model code looks like this.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class People_model extends CI_Model {

	public function get_people()
	{
 		$query = $this→db→get('people');
		return $query->result();
 	}
}

For more information you can refer to the online Model documentation.

We will be using MySql as the data engine. You should have MySql or one of it’s derivatives in your hosting account. 

We need to create a database, a table, and populate it with data.

To do so we need to:

  1. Create a database user. 
  2. Create a database.
  3. Create a table.
  4. Populate the database.
  5. Configure CodeIgniter so it will know about the database and be able to use it. 
  6. Create the model (listed above).

I’m going to make a simple database with a table that contains three names.

  1. Tom Cruise
  2. Tom Selleck
  3. Matt Damon

The SQL for Creating the Database

CREATE DATABASE contacts

The SQL That Creates the Table

CREATE TABLE `people` (
  `id` int(11) NOT NULL,
  `FirstName` varchar(100) NOT NULL,
  `LastName` varchar(100) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

The SQL That Inserts (adds) the Data to the Table

INSERT INTO `people` (`id`, `FirstName`, `LastName`) VALUES
(1, 'Tom', 'Cruise'),
(2, 'Tom', 'Selleck'),
(3, 'Matt', 'Damon');

Configure the Codeigniter Database 

Edit application/config/database.php

Scroll down until you see the following 4 lines

'hostname' => 'localhost',
'username' => '',
'password' => '',
'database' => '',

Set these values according to your database configuration.

For more information you can refer to the CodeIgniter configuration documentation.

Modify the Welcome Controller

In the welcome controller I added a constructor like this :

public function __construct()
{
 	parent::__construct();
 
 	$this->load->database();
 
}

The constructor was necessary so the database could be initialized.

Then I added two lines to the index function:

$this→load→model('People_model');
$data['people'] = $this->People_model->get_people();

and modified the load->view line by adding $data.

$this->load->view('welcome_message', $data);

This transfers the needed data to the view.

Modify the Welcome View

/application/views/welcome_message.php

Immediately after the <div id=”body”> tag, add:

<ul>
<?php
foreach ($people as $arr) {
	echo '<li>';
	echo $arr->id.' ';
	echo $arr->FirstName.' ';
	echo $arr->LastName.' ';
	echo '</li>';
}
?>
</ul> 

The Output

Image of the CodeIgniter Modified Default Welcome Page

As you can see the three names are listed on the home page.

Everything in CodeIgniter 3 is that easy. 

Related Questions

Is CodeIgniter easy to learn?

CodeIgniter is very easy to learn. If you already know how to program in PHP at the beginner level and understand the basics of Object-Oriented Programming in PHP, then you will find CodeIgniter easy to learn. CodeIgniter has the shortest learning curve of all the PHP Frameworks.

How long does it take to learn CodeIgniter?

To learn CodeIgniter might take 10 to 15 days if you spend 2 hours a day studying CodeIgniter. Hands-on is very important. If you follow the brief tutorial listed above, you will be well on your way. Learning Codeigniter comes down to understanding how to create models, views, controllers, and how to implement and use the helpers and libraries. 

Is CodeIgniter Still Relevant? 

CodeIgniter has lost a lot of its popularity since Rick Ellis decided to give CodeIgniter to a new home.

On July 9th, 2013, Rick Ellis, the founder of EllisLab, announced he was looking for a new home for CodeIgniter. At that time CodeIgniter was arguably the most popular PHP framework. Click here to read Ellis’ online statement – EllisLab is seeking a new owner for codeigniter

That announcement set the stage for 2 things to happen. First, it threw the Codeigniter community into chaos because the future was unknown. Because of that a lot of developers fled to other PHP frameworks. After the dust cleared it appears most of the developers moved to Laravel. The second thing put in motion was CodeIgniter would become like the other PHP frameworks. Its footprint would increase, it would become more complicated and harder to learn. Ellis said it: “

PHP as a language is maturing, and CodeIgniter deserves to take advantage of its new stabilized features.”.

This announcement was a death sentence for CodeIgniter. CodeIgniter 4 contains Namespace and utilizes PHP Composer. These two are not necessarily needed and add to the learning curve.

CodeIgniter is slowly losing what sets it apart – being blazing fast, having a small footprint, and being extremely easy to install and learn. 

British Columbia Institute of Technology eventually took control of CodeIgniter

CodeIgniter continues to thrive though. 

If you are looking at CodeIgniter as a future skillset I’d caution you to look beyond. Having said that, there are still COBOL programmers out in the wild. I suspect there will be a need for CodeIgniter developers for a while. 

There is a lot to be learned from using CodeIgniter. Installing and learning how to use it is a great learning experience. I learned a lot from using CodeIgniter and looking at its source code to understand how things work.. 

I learned about Model-View-Controller, and how to modularize my code. When it was all said and done I was able to analyze CodeIgniter to gain the knowledge necessary to develop my small framework. 

Installing and using CodeIgniter will never be waste, it is a great learning opportunity, especially if you go into it with that mindset. 

Is CodeIgniter Dead?

Some think the current owners of CodeIgniter, the British Columbia Institute of Technology, is taking CodeIgniter down the wrong path. 

The downward spiral started the day Rick Ellis announced he was looking for a new home for CodeIgniter. At that very point, the future of CodeIgniter was thrown into chaos. A lot of CodeIgniter users migrated to other PHP frameworks. Most moved to Laravel.

CodeIgniter’s niche used to be that is had a small footprint, was blazing fast, was easy to install, and had a small learning curve. With version 4 in its early days, CodeIgniter is starting down the path towards trying to compete with the other PHP frameworks. Trying to compete with the other PHP frameworks is a mistake. 

CodeIgniter needs to go back to its roots of having a small footprint, being blazing fast, being easy to install, and having a small learning curve.

Google trends show CodeIgniter gets about 60 searches a day.

Image of Google Tends for CodeIgniter

Then when we look at the comparison of CodeIgniter vs Laravel, it looks like CodeIgniter is getting less than 10 searches a day and Laravel is around 75 searches a month.

Image of Google Trends for CodeIgniter vs Laravel

This indicates the interest in CodeIgniter is rather low.

Conclusion

  • This article is a brief look at CodeIgniter. 
  • There is two version – 3 and 4.
  • CodeIgniter is MVC.
  • It has helpers and libraries.
  • It is easy to learn and has a short learning curve of maybe 20 – 30 hours before the developer is ready to start building real-world applications.
  • CodeIgniter has a small footprint, is blazing fast, and easy to learn (version 3).
  • Version 4 is starting down the path away from the roots of CodeIgniter and moving out of its niche.

What is phpMyAdmin and How Does it Work?


This article introduces phpMyAdmin and gives a brief overview of how it works.

phpMyAdmin is free, open source, and was created using the PHP programming language. It was created as a wrapper around the MySql database. PhpMyAdmin is a web interface that gives the user the ability to manage their databases from any device that runs a modern web browser.

What is phpMyAdmin

phpMyAdmin is a free software tool that is used to administer the MySql data engine. It was created in PHP. It was first released in September 1998. Being very mature, it is well documented and widely used. 

Some of the things you can do with phpMySql are create and test SQL queries, manage databases, and manage users.

phpMyAdmin is very feature-rich. It is used as a web interface for the MySql data engine and its derivatives.

I use it often when I need to create a complicated SQL query. SQL stands for Structured Query Language, which is how programmers interface with databases. 

In the next section, we will dig a little deeper.

How Does it Work

Login – To get started one must log in with a MySql username and password. This will give the user access to any databases they have permission to use.

Image of the phpMyAdmin Login Form

The phpMyAdmin Home Page – Once logged in you will see the phpMyAdmin Home Page that will look like the following.

In the upper left area is where you can find the main menu. 

Main Menu Functionality

  • To return to the home page click the “phpMyAdmin” text.
  • The “home” icon returns to the home page as well.
  • The next icon which looks like a door with a green arrow, is the logout button.
  • The round icon that contains a question mark links to the local phpMyAdmin documentation.
  • The icon that looks like a page with a smaller page over it is linked to the MySql reference manual.
  • The gear is liked to the settings pages.
  • The green icon causes the page to refresh when clicked.

Top Menu Functionality

The top menu will be referred to as tabs in this article.

  • Databases – Linked to the databases page.
  • SQL – Linked to one of the two query building pages. This is the less feature-rich version of the two SQL pages.
  • Status – Linked to a stats page. 
  • User account – Links to the user account overview page.
  • Export – Linked to the export database page.
  • Import – Linked to the import page.
  • Settings – Linked to a page that provides for import and export configuration.
  • Replication – Linked to the replication configuration page.
  • Variables – Linked to the server variables and settings page.
  • Charsets – Linked to the character settings and collation page.
  • Engines – Links to the storage engine page.
  • Plugins – Links to the plugins page.

Home Page List of Databases and Tables

On the left side of the home page, you will see a list of databases. By clicking on a database, it will expand to display the tables within that database.

Manage Users

  1. Create a User:
    1. Click the “home” icon, click the “User accounts” tab, then click “Add user account” which is about in the middle of the form.
    2. Complete the form.
  2. Modify a user account:
    1. Click the “home” icon, click the “User Accounts” tab, then click the “Edit privileges” link that is on the same line as the user account you want to modify.
    2. On this page you can:
      • Edit the user’s privileges.
      • Add privileges to other databases.
      • Grant or revoke global privileges.
      • Change the user’s password.
      • Change the login information (username, hostname, password).
  3. Remove a user:
    1. Click the “home” icon.
    2. Click the “User Accounts” tab.
    3. Click the checkbox next to the user you want to remove.
    4. Then select “Drop the databases that have the same names as the users” if you want to remove the database with the same name as the user.
    5. Click the “Go” button.

About User Privileges 

User privileges are what access the user is given. Such as what databases they can see and modify and from where, such as being restricted to the local server.

Manage Databases

  1. Create a database.
    1. Click the “home” icon, click the “Databases” tab.
    2. Enter the Database Name, select the collation, and click the “Create Button” button.
    3. A form will be displayed that allows you to enter the table’s name and the number of fields the table will contain. Complete the form and click on the “Go” button.
    4. Complete the form and click the “Save” button.
  2. Modify Databases.
    1. From the left column of the home page select the database you would like to modify by clicking on the database name. 
    2. The center panel will show all the tables in the database. From this form, you can branch-off to perform other actions to include creating a new table.
  3. Delete or drop a database.
    1. From the left column select the database you would like to drop by clicking on the database name. 
    2. Then click the “Operations” tab.
    3. Under “Remove database” click “Drop the database (DROP)” 

Manage Tables

Image of the phpMyAdmin Database List
  1. Click the home icon, then click the “Databases” tab. You will see a form like the one above.
  2. Click the Database you wish to manage. This will take you to the “Structures” tab. You will be on a form like the one below. This is where you manage your tables.
phpMyAdmin Structures Tab

You can now:

  • Browse – This allows you to “Edit”, “Copy” or, “Delete” each record. You will see the columns along with their data. You can also export data from this screen.
  • Structure – From this screen, you can modify the structure of each field – Change, “Drop”, or you can perform other operations.
  • Search – This allows you to search your data.
  • Insert – This is a form that allows you to add a record to the selected table.
  • Empty – This feature will remove all the records in the table. Be careful with this option.
  • Drop – Allows for the entire table to be removed/destroyed. Be careful with this option.

Note you can also use the list of tables in the left panel to drill down from your database to a table, and the table’s fields.

About Collation

Collation defines how to sort or how to weigh items in relevance to other items. For more information read the MySql documentation on supported character sets and collations [https://dev.mysql.com/doc/refman/8.0/en/charset-charsets.html] Notice MySql recommends you test your selected collation to ensure you are getting the results you desire.

Import Data

  1. From the top menu click on “Import”. 
  2. A form will appear. Click “Choose File”, which will open dialog page for selecting the file you want to import. To the right of “Choose File”, you will see the max file size that you can import. The value can be adjusted. Modifying this value is outside the scope of this article.
  3. Select the “Character Set”.
  4. Set or unset Partial Imports.
  5. Set or unset Enable foreign key check.
  6. Set the file format.
  7. Set the SQL compatibility mode or leave it at its default of none.
  8. Set or unset “Do not use AUTO_INCREMENT for zero values”.
  9. Click the “Go” button.

Export Data

  1. From the top menu click on “Export”. 
  2. Select the “Export method”:
    1. Quick – display only the minimal options.
    2. Custom – display all possible options.
  3. Select the “Format” from the drop-down.
  4. Click the “Go” button. 

SQL Queries

phpMyAdmin Plain SQL interface

SQL stands for Structured Query Language. This is another area you will want to become familiar with. SQL is your bread and butter when it comes to working with databases. I use the SQL box to build complex SQL statements.

There are two ways to get to the query interface.

  1. Click the “home” icon, then click the “SQL” tab to get to the plain SQL interface:
  1. From almost any page you can click the table under a database on the left column and then click the “SQL” tab. That will bring up an SQL interface that has a lot of features you will probably find useful. From here you can click any of the buttons that are directly below the query box. The cool part of this is it will create the type of query you want to create based on the table you selected. This is a great way from a beginner to learn SQL. 
Image of the phpMyAdmin Query Builder

The buttons I want to point out are:

  • <Select *> – Will create a wild card select (a select pulls data).
  • <Select> – Will create a select listing all the fields in the table. 
  • <Insert> – Will create an insert query. This query contains all the fields of the table (an insert creates a new record and populates it).
  • <Update> – Will create an update query. This query contains all the fields of the selected table and place holders for the data that is to be updated (an update query is used to update data). 
  • <Delete> – Will create delete query ( a delete removes a record). 
  • <Clear> – Will clear the text box. 
  • <Format> – This will format the query so it can be used within a program.

phpMyAdmin Documentation

There is a lot to know. This article does not cover everything. This link will take you to the phpMyAdmin documentation where you can learn more.

Conclusion

There are a number of tools you can use to manage your MySql data, each has different features you might find useful.

The nice thing about phpMyAdmin is it is a web application, meaning it runs in a browser. That means you can access phpMyAdmin from any device that runs a modern browser.

phpMyAdmin is very feature-rich and is a great tool for programmers and system administrators. 

11 SEO Tips for the Small Business


Search Engine Optimization or SEO is easy if you know what you are doing and is difficult and frustrating if you do not.

  1. My SEO History
  2. Title Tags
  3. Meta Tags
  4. Permalinks
  5. Focus On a Keyphrase
  6. Turn on Pingbacks
  7. Use Alt Tags
  8. Interlink
  9. WWW or Non-WWW
  10. Sign-Up to Google Search Console
  11. Content is King
  12. Building Links

My SEO History

My path is not without its failures.  Here is my story.

In 2002 I was a freelance desktop application developer.  I was trying to figure out how to market my skills. A friend of mine had been talking about SEO so I thought that was the answer.  With little understanding I set out to build a website for Tucson Custom Software.  About 9 months later I got a call from a guy that was looking for some help with a Word document.

In 2004 I ran into a guy that claimed he knew SEO.  I told him my story and showed him my website ranked number 1 for “Tucson Custom Software”.  He looked at my website and then jumped on his computer and told me no one was searching  “Tucson Custom Software”.  He was very nice about it and showed me what I was missing.  He showed me I needed to research what people are searching for and use those terms to build my website.

Back then I was building websites from scratch.  Not today.  Now I use WordPress to build websites.

WordPress Makes SEO Easier

WordPress SEO is easier than those sites I used to build from scratch.  I spend a lot of time on Drupal and found it to be time consuming to get it to the same place WordPress is right out of the box. Right out of the box WordPress is ready for SEO.  Be careful that the

Title Tags

The title of your pages / articles is very important.  The page / article title tag is important to Google.  Google uses the title taqg to determine what your page / article is about.  This will effect this particular page / article ranking and may effect how your whole site is seen.  The title tag should be an h1 tag and the page / article should contain only one h1.  The h1 for the WordPress page / article is built into the theme.

One of the things you can do to boost your WordPress SEO is to use search terms in your page / article title.  Only use words that describe or are contained in your copy.

Meta Tags

Permalinks

Focus On a Keyword or Key phrase

The word or phase people use while searching on the search engines (think Google) are referred to as keywords or key phrases.  I refer to them as search terms because that is what they are.

If you do not use Keywords and Key Phrases in your copy your site will take a lot longer to rank and may rank for terms you are not interested in.  Part of WordPress SEO is to use the search terms people are using to search for your products, services, and content.  Keywords and Key Phrases tell the search engines (think Google) what your content is about and to a greater extent what your website is about.

Be sure to use your chosen Keywords and Key Phrases sparingly so you do not over optimize your website, which could lead to a penalty on Google.

Turn on Pingbacks

Use Alt Tags

WWW or Non-WWW

Sign-Up to Google Search Console

SEO is supposed to be about all the search engines.  Over the years all of the traffic to mi=y website comes from Google with rare exception.  The current Google Search Console give a lot of information.  It will tell you waht terms your website ranks for and what the ranking is.  This alone is worth it’s weight in gold.  You can use this to track your and validate your SEO campaingn.  Great information.

Content is King

Title

Meta Tags

description

legith

KeyWord Usage

Uniqueue

This is an interesting one.  I used to be obsessed with back links or links from someone else’s website to mine.  Then I realized we are all in the same boat.  We want back links and they are hard to come by.

You will hear stories about link bate.  Stories about the guy that wrote this really cool article that went viral and he got tons of links to that article.  Who is this guy?  Do you know him?  I don’t know him, and you probably do not know him either.

So really it comes down to good WordPress SEO optimization and content.  They say content is king.  It takes good content to rank and it takes good content to keep the reader reading.

Skills a PHP Programmer Should Have – a Definitive Guide


There is a lot of skills a PHP developer should have. Here is my list. 

Skills a PHP Programmer Should Have. A PHP developer needs to have a wide range of skills. This includes HTML, Cascading Style Sheets, JavaScript, PHP, MySql, and Linux. Along with this he or she should possess a strong understanding of security, good communication skills and, don’t forget decent project management skills.

HTML

HTML is the backbone or the bone structure of web pages. This is the foundation of all the skills a PHP programmer should possess.

Cascading Style Sheets (CSS)

Gives a web page and to a greater extent the entire website it looks and feel. This is the design layer.

JavaScript

JavaScript is a must-have skill for every PHP programmer. JavaScript runs in the browser and gives the programmer the ability to make a website interactive.

AJAX

Asynchronous JavaScript and XML (AJAX) is how JavaScript is applied to make the website interactive. When I think of AJAX I think of the ability to talk with PHP to send and receive data from the server to create fully functional web applications.

Some JavaScript Library Such as jQuery or Angular JS

JavaScript is very quirky, mainly due to the different implementations by the different web browser engines. The different implementations can drive a developer crazy. Luckily the community provides libraries such as jQuery that encapsulate or make these differences transparent to the programmer. 

The PHP Programming Language

A PHP programmer must know most of the following. There is a lot to know.

  • Understand that the PHP Ecosystem consists of the following:
    • PHP runs on a web server that more than likely is a Linux web server. 
    • PHP is Open Source and is native to Linux.
    • PHP works with a database server, more than likely MySql.
    • PHP can do a lot, such as server automation, FTP, work with files, interact with other servers, send emails and a lot more.
  • The Basic Skills a PHP Programmer Should Have
    • How to create a basic PHP script, complete with an opening tag that tells the server the file is a PHP program or script.
    • How to open a database connection and how to interact with the database so that data can be Created, Read, Updated, and Deleted.
    • How to include other PHP programs.
    • Control structures such as if statements and loops.
    • Working knowledge of variables, strings, constants, arrays, user-defined functions, variable scope, mail, cookies, sessions, commenting, and error handling.
    • How to embed PHP in HTML.
  • NameSpace – is a way of structuring “blocks” of code so that naming conventions do not become a problem.
  • Dependency Injection – DI is a design pattern that allows for including other code within the current code set or object, making the injected code available to the calling object.
  • GIT is for revision control. This is a set of commands that aid the developer in managing his / her code and the repository. There are several online repositories such as Github and Bitbucket.
  • Composer is a PHP dependency management system that works at the project level. It can be used for installing an application and managing it as well. Think version control.
  • AutoLoading takes the place of the programmer having to manually include every needed external program file.
  • Design Patterns such as:
    • Model View Controller (MVC) is used to separate the data (model), design (view), and the business logic (controller) in a way that makes development and management easier.
    • The Singleton pattern restricts the instantiate of an object to a single instance. This means the same object can be reused.
    • The Active Record pattern is used to aid the developer in designing database interaction.
    • Entity-Attribute-Value is a data model that is used to describe your data tables. This pattern is supposed to make extending your database easier. I have found this pattern to slow the application excessively.
  • Object-Oriented Programming (OOP) in PHP is a software design that, like its name implies, is based on objects. PHP allows for OOP and is also procedural.
  • Regular Expressions are used to filter data.
  • Website security is a skill all developers should possess.
  • Every developer must have project management skills at a personal level. Being able to manage (plan and execute) a project is a must.

MySql

MySql is a data engine and is the most popular data engine (MySql and it’s clones) used with PHP. There is a lot to know about MySql. Every PHP programmer needs to have a solid grasp of how to implement and use MySql. That includes the Structured Query Language (SQL), which is how PHP interacts with MySql.

A PHP developer needs to know how to use SQL to manage data as well as how to create databases, tables, and indexes.

Understanding database normalization is a huge plus that will help the developer when creating a new project.

Linux

The amount of Linux skills required will vary. From my experience, a seasoned PHP developer will need to know the following about Linux hosting server management. 

  • Be able to add and remove users.
  • Be able to create and manage virtual host configuration.
  • Be able to locate and decipher logs.
  • Be able to identify the correct php.ini file that is used on the server.
  • Be able to configure PHP via the php.ini file.
  • Must understand Mod_Rewrite, why it is used, and how to implement it. 
  • Be able to install and manage phpMyAdmin.
  • Knowledge of, and ability to, manage the .htaccess file.

A PHP programmer is not required to be a full-blown Linux systems administrator. The developer will need at least the listed skills though. 

Troubleshooting

  • How to turn on or off error reporting in PHP.
  • Location of server logs and which log to look in for what.
  • Some full-stack troubleshooting skills (HTML / JavaScript / PHP / MySql / Linux / Networking).

Code Editors

There are a lot of code editors. Every developer has their preference. Some editors are free and some come with a licensing fee. Here is just a couple:

PHPStorm – Made by Jet Brains, PHPStorm is a lightweight smart PHP Integrated Development Environment (IDE) that costs $199.00 for the first year and $159 a year thereafter. I would recommend you get your PHP feet wet before deciding to pay for an editor. 

Visual Studio Code – The source code editor Visual Studio Code is developed by Microsoft. It runs on Windows, Linux, and Mac. It is free and relatively easy to learn. This is where I recommend you start.

Atom – While free, Atom comes with a little bit of a learning curve. I would not recommend Atom for the beginner PHP programmer. Your mileage may vary.

Development and Production Hosting Environments

Development Server – This is where you will do all your development. This can be as simple as a localhost PHP development environment.

Testing Server – After you have done your development you can use a testing server for working with the stakeholders. 

Production Server – This is the server where your final product will do its magic. A production server is a public-facing server. Only fully tested code should make it onto the production server. 

Domain Name System (DNS)

Developers are not system administrators and therefore do not need to know DNS intimately. Eventually, every developer needs to have a working knowledge of DNS. 

Ability to Set and Meet Deadlines

Setting deadlines is based on the ability to estimate how long a task or project can take. Estimating how long a task or project can take, effects a developer’s ability to set deadlines and therefor will also effect meeting that deadline. 

This is a potential problem area. It is very difficult to estimate how long a task or project can take. It may take years to get good at determining how long a task or project may take. 

Project Management

This is a skill that will take a while to develop. As mentioned above, estimating how long a task or project will take is difficult. That is not the only skill required for project management. Project management entails managing the entire project from developing a quote, communicating all concerned at the appropriate time, and pulling together resources as needed to complete the project.  

Soft Skills

Soft skills are big in today’s market place. This list should get you started:

Communications – This is my pet peeve. I say communicate soon and often. As a developer, it is easy to recluse and work a project for a while. I have found the best approach is to get the stakeholders involved as early and as often to ensure a project stays on track. 

How to Work as Part of a Team – It is tough to be a developer working in the cube farm. It requires the ability to play well with others, be helpful, and avoid office politics. It is equally important to pull your weight. 

Ability to Know What is Changing – This one is difficult. How do you keep up with changes? You can become active in professional organizations. Another couple of things you can do is listen to your peers and read the updates on the technologies you are working on.

Know What You Don’t Know – It is extremely difficult to know what you don’t know. This may require a bit of humility. There are a few sources, such as, your coworkers, journals, and professional organization to name a few places where you can become aware of the things that you unaware of. 

Empathy – This is big. I’ve worked in the cube farm where other developers were not very understanding or empathetic. Everyone grows and learns at a different rate. Each person has their strengths and weaknesses. We should show empathy towards others as we would expect them to show towards us.

Patience – Sometimes things take a while. When working in a team environment it is wise to set back and let things work their way out. That does not mean to not be involved. On the contrary, we should be involved while also being patient.

Be Open Minded – Everyone has an idea. Some are better than others. We should solicit input from others and listen to others. This can be very helpful. 

Problem Solving Skills – Every developer needs to be a problem solver. Most often some level of creativity is required when solving problems. 

Accountability – Accepting responsibility is very important and often can become a teachable moment. Also, it will earn you a lot of respect. 

Time Management – Don’t let yourself become distracted. The modern-day comes with a ton of distractions. Keep social media, games, politics, news, etc for outside of work.

Strong Work Ethic – We have all gone to work and got sidetracked or distracted and neglected our assignments. This is something we should avoid. It is always good to show up early, stay a bit late, take only the allotted breaks while staying focused on our assignments.

Additional Skills Required if You Specialize

You will need to have a working knowledge of the ecosystem you plan to specialize in as well as strong PHP programming skills. Each of the following comes with a learning curve.

WordPress – WordPress is very popular, easy to implement, and use. As a developer, you will need to know how to create function files and plugins. The WordPress ecosystem is vast and somewhat complex.

Drupal – As an enterprise application it is not just a CMS. Drupal can be used to create almost any type of web application. Drupal comes with a steep learning curve. 

Joomla – Joomla is a CMS that is not widely used, however it does have some market share. You can plan on a learning curve if you are interested in becoming a Joomla extension developer.

WooCommerce – It is being reported that the WooCommerce market share is expanding at a rate greater than other shopping carts. WooCommerce is a WordPress plugin. If you are familiar with the WordPress Plugin ecosystem, you are well on your way to becoming a WooCommerce developer. 

Magento – I spent a couple of years working with Magento. Magento has an extreme learning curve. I would not recommend Magento unless that is what you are assigned to do. Magento requires a team to make it sing. It is not suited to the one-man-band. If you have your heart set on eCommerce, I would recommend taking a look at WordPress / WooCommerce. The CEO of a Magento agency told me to learn Magento takes about 500 hours of classroom and self-directed training plus about 500 hours of hands-on covering 6 months. Magento is not for the faint of heart.

PHP Frameworks – There are a lot of Open Source PHP Frameworks that are available. My favorite is CodeIgniter. It is well documented and is easy to learn. Worth a look. If you are looking for something a little bit more hardcore look at Laravel. Laravel is the most popular PHP framework at the moment.

The Skills a Freelance PHP Developer Should Have

As a freelancer, you might, and probably will, be working in a vacuum. You will do everything. You will snag projects, do quotes, manage projects, and empty the garbage, all from the comfort of your home office. I’ve listed out a few skills you might consider.

Communication Skills – Again my pet peeve. Your communication skills will need to be of the highest quality. This is a must-have skill. As a freelancer, you will need to interface with other business professionals. They are evaluating you every step of the way. This consists of and is not limited to emails, phone calls, quotes, and articles you have written.

Financial Management – You will need to account for all the money you earn. There will be income, expenses, bank fees, and other expenses. Your bookkeeping needs to be top quality. Don’t forget you will need to report all of this on your taxes at the end of the year. The IRS is watching and will expect your accounting and reporting is in order.

Time Management – As a freelance developer, you are solely responsible for how you utilize your time. If like me, you work from home, there is no one watching. It is easy to get sidetracked or mis-prioritize your time. Time is finite so manage it well.

Self Motivated – You will need to motivate yourself. This is a must-have skill. If you lack it you might want to look for a cube farm and a boss.

Marketing – You will need a marketing plan. What are you selling and to whom? You need to know who your competition is and how you differentiate yourself in the marketplace. Do your research before you jump feet first into consulting.

Sales – Noting happens in business until a sale is made. Unless you are a natural salesperson, you might want to take a course or two to learn a bit about sales before you go out on your own.

In Closing 

As you can see there is a lot to know to become a PHP programmer. And if you want to become a freelance PHP developer there is even more to know.

I hope this information is helpful. I wish you the best on your journey.

Everything a Website Owner Should Know