<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tutorials Archives - Chief of Stack</title>
	<atom:link href="https://www.chiefofstack.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.chiefofstack.com/category/tutorials/</link>
	<description>Full Stack Creative Works by Jay Acab</description>
	<lastBuildDate>Tue, 10 Mar 2026 21:21:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.2</generator>

<image>
	<url>https://www.chiefofstack.com/wp-content/uploads/2020/05/cropped-logo-32x32.jpg</url>
	<title>Tutorials Archives - Chief of Stack</title>
	<link>https://www.chiefofstack.com/category/tutorials/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Easily create a local Laravel development environment with Docker in Windows</title>
		<link>https://www.chiefofstack.com/2021/06/11/easily-create-a-local-laravel-development-environment-with-docker-in-windows/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=easily-create-a-local-laravel-development-environment-with-docker-in-windows</link>
					<comments>https://www.chiefofstack.com/2021/06/11/easily-create-a-local-laravel-development-environment-with-docker-in-windows/#respond</comments>
		
		<dc:creator><![CDATA[Jay Acab]]></dc:creator>
		<pubDate>Fri, 11 Jun 2021 22:00:42 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Laravel]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.chiefofstack.com/?p=2824</guid>

					<description><![CDATA[<p>This article is meant to be a short walkthrough on how to quickly setup a local development environment using Docker, a better alternative to installing a full LAMP stack such as XAMPP on your machine.... </p>
<p class="more"><a class="more-link" href="https://www.chiefofstack.com/2021/06/11/easily-create-a-local-laravel-development-environment-with-docker-in-windows/">Read More</a></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2021/06/11/easily-create-a-local-laravel-development-environment-with-docker-in-windows/">Easily create a local Laravel development environment with Docker in Windows</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This article is meant to be a short walkthrough on how to quickly setup a local development environment using Docker, a better alternative to installing a full LAMP stack such as XAMPP on your machine. This is not a full tutorial on Docker though, I just find this method works the best for me when developing Laravel apps.</p>



<p>Here&#8217;s the GitHub repo for all the code below, you can clone it for easier deployment. <a href="https://github.com/chiefofstack/docker-boilerplate">https://github.com/chiefofstack/docker-boilerplate</a></p>



<h3>What is Docker and what are we going to create anyway?</h3>



<p><em>&#8220;Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and ship it all out as one package.&#8221;</em><br>&#8211; opensource.com</p>



<figure class="wp-block-image size-large"><img width="1024" height="818" src="https://www.chiefofstack.com/wp-content/uploads/2021/06/what-is-docker.jpg" alt="What is Docker" class="wp-image-2878" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/06/what-is-docker.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2021/06/what-is-docker-300x240.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2021/06/what-is-docker-768x614.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2021/06/what-is-docker-550x439.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2021/06/what-is-docker-626x500.jpg 626w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Apps and services like PHP can be packaged and deployed easily.<br>Photo from: <a rel="noreferrer noopener" href="https://www.docker.com/resources/what-container" target="_blank">docker.com</a></figcaption></figure>



<p>In a nutshell, we can think of Docker as a lightweight virtual machine that can be easily deployed across any environment together with all the configurations. This guarantees that your application will run precisely how it&#8217;s intended whether it is in production, staging or in a development environment.</p>



<p>That&#8217;s it, we will create service containers for our entire stack. Let&#8217;s get started!</p>



<h3>Step 1. Install Docker Desktop</h3>



<p>If you are a Windows user, download and install Docker for Windows using this <a href="https://docs.docker.com/docker-for-windows/install/" target="_blank" rel="noreferrer noopener">link</a>. Docker Desktop has a built in tool called <strong>docker-compose</strong> which we will utilize to link our services/containers together.</p>



<p><em>&#8220;Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration.&#8221; </em><em><br></em>&#8211; docker.com</p>



<p>Note that you need WSL 2 configured on your Windows machine before you can install this app.</p>



<h3>Step 2:&nbsp; Create individual containers for each of our services</h3>



<p>Cd into your project directory and run the following commands in your terminal (for this example I used /home/myuser/Sites/awesomeproject.com). these are basically all the files/folders that we need:</p>



<pre class="wp-block-code">$ touch docker-compose.yml
$ touch Dockerfile
$ mkdir src
$ mkdir mysql
$ mkdir nginx
$ touch nginx/default.conf</pre>



<p>Your file structure should look like this.</p>



<figure class="wp-container-2 wp-block-gallery-1 wp-block-gallery has-nested-images columns-default is-cropped">
<figure class="wp-block-image size-large"><img data-id="2842"  src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/step-2-file-our-structure.jpg" alt="" class="wp-image-2842"/></figure>
</figure>



<p>Edit docker-compose.yml and define our networks</p>



<pre class="wp-block-code">version: '3'
networks:
    laravel: </pre>



<p>Next we define the services we will use for our stack. For NGINX add the following code, this will make the server accessible through port 1010. We also mapped the configuration file to default.conf file found in our nginx folder.:</p>



<pre class="wp-block-code">services:
    nginx:
        image: nginx:stable-alpine
        container_name: nginx_awesomeproject.com
        ports:
            - "1010:80"
        volumes:
            - ./src:/var/www/html
            - ./nginx/default.conf:/etc/nginx/conf.d/default.conf
        depends_on:
            - php
            - mysql
            - phpmyadmin
        networks:
            - laravel</pre>



<p>Then edit nginx/default.conf and add the following code:</p>



<pre class="wp-block-code">server {
    listen 80;
    index index.php index.html;
    server_name localhost;
    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
    root /var/www/html/public;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}</pre>



<p>For PHP edit docker-composer.yml again and add the following code. Like the NGINX service above, we prepend the service name php_ for our container_name, used a unique port 1000 so it doesn’t interfere with other local ports in our system and linked it to our container using the ‘laravel’ network. We also added a custom docker file ‘Dockerfile’:</p>



<pre class="wp-block-code">   php:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: php_awesomeproject.com
        volumes:
            - ./src:/var/www/html
        ports:
            - "1000:9000"
        networks:
            - laravel</pre>



<p>Edit Dockerfile and add the following code, this will install php: 7.4-fpm-alpine and also install php extensions.</p>



<pre class="wp-block-code">FROM php:7.4-fpm-alpine
RUN docker-php-ext-install pdo pdo_mysql</pre>



<p>For MySQL add the following to docker-composer.yml.  Here we defined the MySQL credentials that we will use in our Laravel installation. And just like with the previous two service, we linked them up using the “laravel” network</p>



<pre class="wp-block-code">    mysql:
        image: mysql:5.7.22
        container_name: mysql_awesomeproject.com
        restart: unless-stopped
        tty: true
        ports: 
            - "1306:3306"
        volumes:
            - ./mysql_awesomeproject.com:/var/lib/mysql
        environment:
            MYSQL_DATABASE: homestead
            MYSQL_USER: homestead
            MYSQL_PASSWORD: secret
            MYSQL_ROOT_PASSWORD: secret
            SERVICE_TAGS: dev
            SERVICE_NAME: mysql
        networks:
            - laravel</pre>



<p>There you go, if all you want is a basic LEMP stack you can skip to the next step. But in order to make our dev environment even more complete I recommend you go ahead and install the following tools.</p>



<p>We will configure Artisan, the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application.:</p>



<pre class="wp-block-code">    artisan:
        build:
            context: .
            dockerfile: Dockerfile
        container_name: artisan_awesomeproject.com
        volumes:
            - ./src:/var/www/html
        depends_on:
            - mysql
        working_dir: /var/www/html
        entrypoint: &#91;'/var/www/html/artisan']
        networks:
            - laravel</pre>



<p></p>



<p>We will add Composer, a dependency manager for PHP:</p>



<pre class="wp-block-code">    composer:
        image: composer:latest
        container_name: composer_awesomeproject.com
        volumes:
            - ./src:/var/www/html
        working_dir: /var/www/html
        depends_on:
            - php
        networks:
            - laravel</pre>



<p>Next we add Node Package Manager. NPM is a package manager for JavaScript.</p>



<pre class="wp-block-code">    npm:
        image: node:13.7
        container_name: npm_awesomeproject.com
        volumes:
            - ./src:/var/www/html
        working_dir: /var/www/html
        entrypoint: &#91;'npm']
        networks:
            - laravel</pre>



<p>I also love to use PHPMyAdmin, a free and open source administration tool for MySQL and MariaDB.</p>



<pre class="wp-block-code">    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        container_name: phpmyadmin_awesomeproject.com
        restart: always
        depends_on:
            - mysql
        ports:
            - 1011:80
        environment:
            PMA_HOST: mysql
            PMA_USER: root
            PMA_PASSWORD: secret            
            PMA_ARBITRARY: 1
        networks:
            - laravel</pre>



<p>Your docker-compose.yml file should look like this.&nbsp;</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="796" src="https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-1024x796.jpg" alt="docker-compose.yml" class="wp-image-2863" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-1024x796.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-300x233.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-768x597.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-1536x1194.jpg 1536w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-1060x824.jpg 1060w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-550x427.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-643x500.jpg 643w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_-1390x1080.jpg 1390w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose.yml_.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>With this file we were able to link our containers using the network &#8220;laravel&#8221;, added volumes to each of our containers and defined the images to be used when we run it later. Those images are available from the Docker library. We were also able to install tools necessary for a better Laravel development experience.</p>



<h3>Step 3: Run the containers and access it locally&nbsp;</h3>



<p>In your terminal run the following in your project folder, this will build and run the containers all in one go. Note that Artisan will fail to run but we will solve that on the next step:</p>



<pre class="wp-block-code">~ docker-compose up -d --build</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="806" height="453" src="https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose-up-d-build.jpg" alt="" class="wp-image-2870" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose-up-d-build.jpg 806w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose-up-d-build-300x169.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose-up-d-build-768x432.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-compose-up-d-build-550x309.jpg 550w" sizes="(max-width: 806px) 100vw, 806px" /></figure>



<p>To test, run this command to list all running containers:</p>



<pre class="wp-block-code">~ docker ps/</pre>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="103" src="https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-ps-1024x103.jpg" alt="" class="wp-image-2871" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-ps-1024x103.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-ps-300x30.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-ps-768x77.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-ps-1060x107.jpg 1060w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-ps-550x55.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2021/06/docker-ps.jpg 1164w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>You can then check http://localhost:1010 to see if the NGINX server is properly running, right now we don’t have a placeholder index.html there so it will naturally return a 404 error</p>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/nginx-localhost-1010.jpg" alt="" class="wp-image-2840"/></figure>



<p>To be able to see the database go to http://localhost:1011, where you will see PHPMyAdmin</p>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/phpmyadmin-localhost-1010.jpg" alt="" class="wp-image-2841"/></figure>



<p>You can connect to mysql through the terminal as well with this code:</p>



<pre class="wp-block-code">~ docker-compose exec mysql mysql -u root -p</pre>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/docker-compose-exec-mysql.jpg" alt="" class="wp-image-2832"/></figure>



<p>Lastly, you can take the containers down using the following commands:</p>



<pre class="wp-block-code">~ docker-compose down</pre>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/docker-compose-down.jpg" alt="" class="wp-image-2831"/></figure>



<h3>Final Step: Install Laravel and test the tools</h3>



<p>If you’ve gone this far you would’ve encountered an error when we ran the artisan container earlier. It’s because we do not have Laravel installed in the /src folder yet. We will do that now,&nbsp; cd into your /src folder and run the following composer command:</p>



<pre class="wp-block-code">~ composer create-project laravel/laravel .</pre>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/docker-compose-create-project-laravel.jpg" alt="" class="wp-image-2830"/></figure>



<p>Configure the .env file to match the MySQL credentials we defined earlier in docker-compose.yml. Your .env file should look like this.<br></p>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/laravel-env-file.jpg" alt="" class="wp-image-2838"/></figure>



<p>To install a Laravel package using Composer run the following command (we’ll install Socialite for this example):</p>



<pre class="wp-block-code">~ docker-compose run --rm composer require laravel/socialite</pre>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/docker-compose-composer-require-laravel-socialite.jpg" alt="" class="wp-image-2829"/></figure>



<p>Let’s now test how to compile assets:</p>



<pre class="wp-block-code">~ docker-compose run -rm npm run dev</pre>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/docker-compose-run-npm-run-dev.jpg" alt="" class="wp-image-2834"/></figure>



<p>Let’s test Artisan by issuing a migrate command:</p>



<pre class="wp-block-code">~ docker-compose run -rm artisan migrate</pre>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/docker-compose-run-artisan-migrate.jpg" alt="" class="wp-image-2833"/></figure>



<p>Go back to your browser to test the Laravel installation:</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="679" src="https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete-1024x679.jpg" alt="" class="wp-image-2874" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete-1024x679.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete-300x199.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete-768x509.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete-1060x703.jpg 1060w, https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete-550x365.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete-754x500.jpg 754w, https://www.chiefofstack.com/wp-content/uploads/2021/06/laravel-installation-complete.jpg 1235w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3>Bonus Step:</h3>



<p>I edited my Linux .bashrc file and added &#8220;dcr&#8221; as an alias for &#8220;docker-compose run -rm&#8221; command.</p>



<figure class="wp-block-image size-large"><img src="https://www.chiefofstack.com/public_html/wp-content/uploads/2021/06/edit-bashrc-file-add-docker-compose-alias.jpg" alt="" class="wp-image-2837"/></figure>



<p>This will make it easier to run the tools using the following shorthand &#8220;dcr npm run dev&#8221;, &#8220;dcr artisan migrate&#8221;, “dcr composer install”.&nbsp;</p>



<p>SOURCES:<br><a href="https://opensource.com/resources/what-docker" target="_blank" rel="noreferrer noopener">https://opensource.com/resources/what-docker</a><br><a href="https://docs.docker.com/compose/" target="_blank" rel="noreferrer noopener">https://docs.docker.com/compose/</a></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2021/06/11/easily-create-a-local-laravel-development-environment-with-docker-in-windows/">Easily create a local Laravel development environment with Docker in Windows</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.chiefofstack.com/2021/06/11/easily-create-a-local-laravel-development-environment-with-docker-in-windows/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Basic AJAX CRUD app using PHP, MySQL and jQuery</title>
		<link>https://www.chiefofstack.com/2021/01/23/basic-ajax-crud-app-using-php-mysql-and-jquery/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=basic-ajax-crud-app-using-php-mysql-and-jquery</link>
					<comments>https://www.chiefofstack.com/2021/01/23/basic-ajax-crud-app-using-php-mysql-and-jquery/#comments</comments>
		
		<dc:creator><![CDATA[Jay Acab]]></dc:creator>
		<pubDate>Sat, 23 Jan 2021 23:33:27 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.chiefofstack.com/?p=2797</guid>

					<description><![CDATA[<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2021/01/23/basic-ajax-crud-app-using-php-mysql-and-jquery/">Basic AJAX CRUD app using PHP, MySQL and jQuery</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="vc_row wpb_row vc_row-fluid"><div class="wpb_column vc_column_container vc_col-sm-12"><div class="vc_column-inner"><div class="wpb_wrapper">
	<div class="wpb_text_column wpb_content_element " >
		<div class="wpb_wrapper">
			<p>We are going to build a basic AJAX CRUD app from scratch using only PHP, MySQL and jQuery AJAX. CRUD is an acronym for Create, Read, Update, Delete. Basic operations that are at the heart of all web apps.</p>
<p>We will use Bootstrap for the layout and utilize other jQuery plugins for the UI.</p>
<p>But first, the file structure.</p>
<p><strong>/db</strong> &#8211; The directory that has all the server and database related files </p>
<ol>
<li><strong>env.php</strong> &#8211; environment settings for database, server and miscellaneous display options</li>
<li><strong>generate-db.php</strong> &#8211; creates a database based on the details set in the env. file</li>
<li><strong>create-table.php</strong> -creates a table based on the details set in the env. file</li>
<li><strong>connect-db.php </strong>&#8211; global include for databases connection</li>
</ol>
<p><strong>/api</strong> &#8211; The directory that has all endpoint related files </p>
<ol>
<li><strong>create.php</strong> &#8211; all the code and mySQL statements for inserting records</li>
<li><strong>delete.php</strong> &#8211; all the code and mySQL statements  for deleting records</li>
<li><strong>index.php</strong> &#8211; all the code and mySQL statements  for showing rows based on the current page</li>
<li><strong>update.php </strong>&#8211; all the code and mySQL statements  for updating records</li>
</ol>
<p><strong>/js/index.js</strong> &#8211; The file that handles all page events </p>
<ol>
<li><strong>displayBookList() </strong>&#8211; displays the initial list of all books with pagination</li>
<li><strong>displayPageEntries() &#8211;</strong> displays books for the current page</li>
<li><strong>refreshList(data) </strong>&#8211;  universal function to refresh the content of the table, takes in data.</li>
<li><strong>View book</strong> &#8211; has all the code to display a record</li>
<li><strong>Create book</strong> &#8211; code to add a new record</li>
<li><strong>Edit book </strong> &#8211; all the code to fill in the edit form with current data</li>
<li><strong>Update book </strong>&#8211; code to update a record</li>
</ol>
<p><strong> /index.php</strong> &#8211; Is the main file that contains all elements, our app will use modal windows to display the forms. </p>
<figure class="wp-block-image size-large"><img loading="lazy" width="298" height="382" class="wp-image-2799" src="https://www.chiefofstack.com/wp-content/uploads/2021/01/file-structure.jpg" alt="" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/01/file-structure.jpg 298w, https://www.chiefofstack.com/wp-content/uploads/2021/01/file-structure-234x300.jpg 234w" sizes="(max-width: 298px) 100vw, 298px" /></figure>
<p>Let&#8217;s start.</p>
<p><strong>Step 1: Take care of the database. </strong>These files are for global use but create-table.php and generate-db.php are used only once.</p>
<p><em>.env.php</em> </p>
<pre class="wp-block-code">&lt;?php
// Database info
$server = "localhost";
$user = "root";
$pass = "";
$db_name = "awesomedb";
$table_name = "books";

// Server URL
$url = "http://localhost/";

$display_rows = 10;

?&gt;</pre>
<p><em>generate-db.php</em> </p>
<pre class="wp-block-code">&lt;?php
include_once("env.php");

// Create connection
$connection = new mysqli($server, $user, $pass);

// Check connection
if ($connection-&gt;connect_error) {
    die("ERROR: Could not connect " . $connection-&gt;connect_error);
}

// Create new database
$sql = "CREATE DATABASE `$db_name`";

if($connection-&gt;query($sql) === TRUE){
    echo "Database created successfully";
} else {
    echo "ERROR: Unable to execute $sql. " . $connection-&gt;error;
}

// Close connection
$connection-&gt;close();

?&gt;</pre>
<p><em>create-table.php</em> </p>
<pre class="wp-block-code">&lt;?php
include_once("connect-db.php");

// Create new table
$sql = "CREATE TABLE `$table_name` (
            id INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            title VARCHAR(191) NOT NULL,
            author VARCHAR(191) NOT NULL,
            published_date DATE,
            last_modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
            status ENUM('active', 'pending', 'deleted')
        )";

if($connection-&gt;query($sql) === TRUE){
    echo "Table '".$table_name."' created successfully";
} else {
    echo "Error creating table: " . $connection-&gt;error;
}
 
// Close connection
$connection-&gt;close();

?&gt;</pre>
<p><em>connect-db.php</em> </p>
<pre class="wp-block-code">&lt;?php
include_once("env.php");

// Create connection
$connection = new mysqli($server, $user, $pass, $db_name);

// Check connection
if ($connection-&gt;connect_error) {
    die("ERROR: Could not connect " . $connection-&gt;connect_error);
}
 

?&gt;</pre>
<p><strong>Step 2: Prepare the endpoints. </strong>These files run the mySQL queries for the operations. This is where the magic actually happens.</p>
<p><em>create.php</em> </p>
<pre class="wp-block-code">&lt;?php
require_once('../db/connect-db.php');

// Add new record
$sql = "INSERT INTO `$table_name` ( `title`, `author`, `published_date`) VALUES ( '".$_POST['title']."', '".$_POST['author']."', '".$_POST['published_date']."')";
$result = $connection-&gt;query($sql);

// Return value
$sql = "SELECT * FROM $table_name ORDER BY id DESC LIMIT 1";
$result = $connection-&gt;query($sql);
$data = $result-&gt;fetch_assoc();
echo json_encode($data);
?&gt;</pre>
<p><em>index.php</em> </p>
<pre class="wp-block-code">&lt;?php
require_once('../db/connect-db.php');
 
$page = (isset($_GET["page"])) ? $_GET["page"] : 1;
$start_from = ($page-1) * $display_rows;

// Get all rows for selected page
$sql = "SELECT * FROM $table_name ORDER BY id DESC LIMIT $start_from, $display_rows";
$result = $connection-&gt;query($sql);
while($row = $result-&gt;fetch_assoc()){
    $json[] = $row;
}
$data['data'] = $json;

// Get total count of all books
$sql = "SELECT COUNT(*) AS total FROM $table_name";
$result = $connection-&gt;query($sql);
$values = mysqli_fetch_assoc($result);
$data['total'] = $values['total'];

// Return books
echo json_encode($data);
?&gt;
</pre>
<p><em>update.php</em> </p>
<pre class="wp-block-code">&lt;?php
require_once('../db/connect-db.php');

// Update record
$sql = "UPDATE `$table_name` SET `title` = '".$_POST['title']."', `author` = '".$_POST['author']."', `published_date` = '".$_POST['published_date']."' WHERE `id` = ".$_POST['id']."";
$result = $connection-&gt;query($sql);

// Return value
$sql = "SELECT * FROM $table_name WHERE `id` = '".$_POST['id']."'";
$result = $connection-&gt;query($sql);
$data = $result-&gt;fetch_assoc();
echo json_encode($data);
?&gt;</pre>
<p><em>delete.php</em> </p>
<pre class="wp-block-code">&lt;?php
require_once('../db/connect-db.php');
$id  = $_POST["id"];

// Delete record
$sql = "DELETE FROM $table_name WHERE id = '".$id."'";

if($connection-&gt;query($sql) === TRUE){
    echo json_encode([$id]);
} else {
    echo "Error deleting record " . $connection-&gt;error;
}

// Close connection
$connection-&gt;close(); 
?&gt;</pre>
<p><strong>Step 3: Design the user interface. </strong>Page elements like lists, pagination, buttons and modal windows allows for user interaction. We used a few jQuery plugins to improve  the UI like twbsPagination, bootstrap-validator, jQueryUI and toast to display notifications </p>
<figure class="wp-block-image size-large"><img loading="lazy" width="1190" height="759" class="wp-image-2806" src="https://i1.wp.com/www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1.jpg?fit=710%2C453&amp;ssl=1" alt="" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1.jpg 1190w, https://www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1-300x191.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1-1024x653.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1-768x490.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1-1060x676.jpg 1060w, https://www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1-550x351.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2021/01/deleted-1-784x500.jpg 784w" sizes="(max-width: 1190px) 100vw, 1190px" /></figure>
<figure class="wp-block-image size-large"><img loading="lazy" width="1184" height="777" class="wp-image-2807" src="https://i1.wp.com/www.chiefofstack.com/wp-content/uploads/2021/01/edit-1.jpg?fit=710%2C466&amp;ssl=1" alt="" srcset="https://www.chiefofstack.com/wp-content/uploads/2021/01/edit-1.jpg 1184w, https://www.chiefofstack.com/wp-content/uploads/2021/01/edit-1-300x197.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2021/01/edit-1-1024x672.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2021/01/edit-1-768x504.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2021/01/edit-1-1060x696.jpg 1060w, https://www.chiefofstack.com/wp-content/uploads/2021/01/edit-1-550x362.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2021/01/edit-1-762x500.jpg 762w" sizes="(max-width: 1184px) 100vw, 1184px" /></figure>
<p><em>index.php</em> </p>
<pre class="wp-block-code">&lt;?php require_once("db/env.php"); ?&gt;
&lt;!doctype html&gt;
&lt;html lang="en"&gt;
    &lt;head&gt;
        &lt;!-- Meta tags --&gt;
        &lt;meta charset="utf-8"&gt;
        &lt;meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"&gt;

        &lt;!-- CSS --&gt;
        &lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"&gt;
        &lt;link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"&gt;

        &lt;!-- JS --&gt;
        &lt;script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"&gt;&lt;/script&gt;
        &lt;script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"&gt;&lt;/script&gt;
        &lt;script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"&gt;&lt;/script&gt;
        &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/twbs-pagination/1.4.2/jquery.twbsPagination.min.js" integrity="sha512-frFP3ZxLshB4CErXkPVEXnd5ingvYYtYhE5qllGdZmcOlRKNEPbufyupfdSTNmoF5ICaQNO6SenXzOZvoGkiIA==" crossorigin="anonymous"&gt;&lt;/script&gt;
        &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.5/validator.min.js"&gt;&lt;/script&gt;
	    &lt;script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/js/toastr.min.js"&gt;&lt;/script&gt;
        &lt;link href="//cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/css/toastr.min.css" rel="stylesheet"&gt;

        &lt;!-- Custom JS  --&gt;
        &lt;script type="text/javascript"&gt;
            var url = "&lt;?php echo $url; ?&gt;";
            var display_rows = "&lt;?php echo $display_rows; ?&gt;";

            $(function(){
                $("#published_date").datepicker({ dateFormat: 'yy-mm-dd' });
                $("#published_date_edit").datepicker({ dateFormat: 'yy-mm-dd' });
            });
        &lt;/script&gt;

        &lt;!-- API JS files --&gt;
        &lt;script src="js/index.js"&gt;&lt;/script&gt;

        &lt;title&gt;Trial Project for Worker Bee TV - Submitted by Jay Acab chiefofstack.com &lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;div class="container"&gt;
            &lt;div class="row mt-4"&gt;
    		    &lt;div class="col-lg-12"&gt;
    		        &lt;div class="float-left"&gt;
    		            &lt;h2&gt;Books&lt;/h2&gt;
    		        &lt;/div&gt;
    		        &lt;div class="float-right"&gt;
        				&lt;button type="button" class="btn btn-success" data-toggle="modal" data-target="#create-book"&gt;
        					Add New Book
        				&lt;/button&gt;
    		        &lt;/div&gt;
    		    &lt;/div&gt;
    		&lt;/div&gt;

    		&lt;table class="table table-bordered table-striped text-muted text-center mt-3"&gt;
    			&lt;thead&gt;
    			    &lt;tr&gt;
        				&lt;th&gt;Date Published&lt;/th&gt;
        				&lt;th&gt;Author name&lt;/th&gt;
                        &lt;th&gt;Book Title&lt;/th&gt;
        				&lt;th&gt;Action&lt;/th&gt;
    			    &lt;/tr&gt;
    			&lt;/thead&gt;
    			&lt;tbody&gt;
    			&lt;/tbody&gt;
    		&lt;/table&gt;

    		&lt;ul id="pagination" class="pagination-sm"&gt;&lt;/ul&gt;
        &lt;/div&gt;

        &lt;!-- View Book Modal --&gt;
        &lt;div id="view-book" class="modal"  tabindex="-1" role="dialog" aria-labelledby="modalLabel"&gt;
            &lt;div class="modal-dialog" role="document"&gt;
                &lt;div class="modal-content"&gt;
                    &lt;div class="modal-header"&gt;
                        &lt;div&gt;
                            &lt;h4 class="modal-title float-left" id="modalLabel"&gt;Book Information&lt;/h4&gt;
                        &lt;/div&gt;
                        &lt;div&gt;
                            &lt;button type="button" class="close float-right" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;×&lt;/span&gt;&lt;/button&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="modal-body"&gt;
                        &lt;form id="view-book-form" data-toggle="validator" action="api/create.php" method="POST"&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="title"&gt;Title:&lt;/label&gt;
                                &lt;p id="title_view" name="title" class="font-weight-bold" /&gt;&lt;/p&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="author"&gt;Author:&lt;/label&gt;
                                &lt;p id="author_view" name="author"  class="font-weight-bold"/&gt;&lt;/p&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="published_date"&gt;Date Published:&lt;/label&gt;
                                &lt;p id="published_date_view" name="published_date" class="font-weight-bold" /&gt;&lt;/p&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="id"&gt;ID:&lt;/label&gt;
                                &lt;p id="id_view" name="id" class="font-weight-bold" /&gt;&lt;/p&gt;
                            &lt;/div&gt;
                        &lt;/form&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;

        &lt;!-- Create Book Modal --&gt;
        &lt;div id="create-book" class="modal"  tabindex="-1" role="dialog" aria-labelledby="modalLabel"&gt;
            &lt;div class="modal-dialog" role="document"&gt;
                &lt;div class="modal-content"&gt;
                    &lt;div class="modal-header"&gt;
                        &lt;div&gt;
                            &lt;h4 class="modal-title float-left" id="modalLabel"&gt;Add a Book&lt;/h4&gt;
                        &lt;/div&gt;
                        &lt;div&gt;
                            &lt;button type="button" class="close float-right" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;×&lt;/span&gt;&lt;/button&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="modal-body"&gt;
                        &lt;form id="create-book-form" data-toggle="validator" action="api/create.php" method="POST"&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="title"&gt;Title:&lt;/label&gt;
                                &lt;input type="text" id="title" name="title" class="form-control" data-error="Please enter book title." required /&gt;
                                &lt;div class="help-block with-errors text-danger"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="author"&gt;Author:&lt;/label&gt;
                                &lt;input type="text" id="author" name="author" class="form-control" data-error="Please enter the name of the author." required&gt;
                                &lt;div class="help-block with-errors text-danger"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="published_date"&gt;Date Published:&lt;/label&gt;
                                &lt;input type="text" id="published_date" name="published_date" class="form-control" data-error="Please enter the date when the book was published." required autocomplete="off"&gt;
                                &lt;div class="help-block with-errors text-danger"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group mt-4"&gt;
                                &lt;button type="submit" class="btn submit-book btn-success"&gt;Submit&lt;/button&gt;
                            &lt;/div&gt;
                        &lt;/form&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;

        &lt;!-- Edit Book Modal --&gt;
        &lt;div id="edit-book" class="modal"  tabindex="-1" role="dialog" aria-labelledby="modalLabel"&gt;
            &lt;div class="modal-dialog" role="document"&gt;
                &lt;div class="modal-content"&gt;
                    &lt;div class="modal-header"&gt;
                        &lt;div&gt;
                            &lt;h4 class="modal-title float-left" id="modalLabel"&gt;Edit Book&lt;/h4&gt;
                        &lt;/div&gt;
                        &lt;div&gt;
                            &lt;button type="button" class="close float-right" data-dismiss="modal" aria-label="Close"&gt;&lt;span aria-hidden="true"&gt;×&lt;/span&gt;&lt;/button&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;div class="modal-body"&gt;
                        &lt;form id="edit-book-form" data-toggle="validator" action="api/update.php" method="put"&gt;
                            &lt;input type="hidden" id="id" name="id" class="edit-id"&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="title_edit"&gt;Title:&lt;/label&gt;
                                &lt;input type="text" id="title_edit" name="title" class="form-control" data-error="Please enter book title." required /&gt;
                                &lt;div class="help-block with-errors text-danger"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="author_edit"&gt;Author:&lt;/label&gt;
                                &lt;input type="text" id="author_edit" name="author" class="form-control" data-error="Please enter the name of the author." required&gt;
                                &lt;div class="help-block with-errors text-danger"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group"&gt;
                                &lt;label class="control-label" for="published_date_edit"&gt;Date Published:&lt;/label&gt;
                                &lt;input type="text" id="published_date_edit" name="published_date" class="form-control" data-error="Please enter the date when the book was published." required autocomplete="off"&gt;
                                &lt;div class="help-block with-errors text-danger"&gt;&lt;/div&gt;
                            &lt;/div&gt;
                            &lt;div class="form-group mt-4"&gt;
                                &lt;button type="submit" class="btn submit-book-edit btn-success"&gt;Submit&lt;/button&gt;
                            &lt;/div&gt;
                        &lt;/form&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;

    &lt;/body&gt;
&lt;/html&gt;</pre>
<p><strong>Step 4: Handle the events. </strong>This file brings your page to life. It connects page events to the endpoints to complete the operation.</p>
<p><em>index.js</em> </p>
<pre class="wp-block-code">$(document).ready(function() {

/* Initialize the index */
var page = 1;
var current_page = 1;
var total_page = 0;
var display = "list";

/* Display Initial List of Books */
if(display=="list")
    displayBookList();
 
/* View book */
$("body").on("click",".view-book",function(){
    var id = $(this).parent("td").data('id');
    var title = $(this).parent("td").prev("td").text();
    var author = $(this).parent("td").prev("td").prev("td").text();
    var published_date = $(this).parent("td").prev("td").prev("td").prev("td").text();
    display = "details";

    $("#id_view").text(id);
    $("#title_view").text(title);
    $("#author_view").text(author);
    $("#published_date_view").text(published_date);
});

/* Create new book */
$('#create-book-form').on('submit', function(e){
    e.preventDefault();
    var form_action = $("#create-book-form").attr("action");
    var title = $("#title").val();
    var author = $("#author").val();
    var published_date = $("#published_date").val();
    display = "create";

    if(title != '' &amp;&amp; author != '' &amp;&amp; published_date !=''){
        $.ajax({
            dataType: 'json',
            type:'POST',
            url: url + form_action,
            data:{
                title:title,
                author:author,
                published_date:published_date
            }
        }).done(function(data){
            // Reset Form
            $("#title").val('');
            $("#author").val('');
            $("#published_date").val('');

            // Display new item on the list
            displayPageEntries();

            // Hide modal
            $("#create-book").modal('hide');
            toastr.success('Item Created Successfully.', 'Success Alert', {timeOut: 5000});
        });
    }else{
        alert('All fields are required. Please make sure you fill out all fields correctly.')
    }
});

/* Edit book */
$("body").on("click",".edit-book",function(){
    var id = $(this).parent("td").data('id');
    var title = $(this).parent("td").prev("td").text();
    var author = $(this).parent("td").prev("td").prev("td").text();
    var published_date = $(this).parent("td").prev("td").prev("td").prev("td").text();
    display = "edit";

    $("#title_edit").val(title);
    $("#author_edit").val(author);
    $("#published_date_edit").val(published_date);
    $("#edit-book-form").find(".edit-id").val(id);
});

/* Update book */
$('#edit-book-form').on('submit', function(e){
    e.preventDefault();

    var form_action = $("#edit-book-form").attr("action");
    var title = $("#title_edit").val();
    var author = $("#author_edit").val();
    var published_date = $("#published_date_edit").val();
    var id = $("#edit-book-form").find(".edit-id").val();


    if(title != '' &amp;&amp; author != '' &amp;&amp; published_date !=''){
        $.ajax({
            dataType: 'json',
            type:'POST',
            url: url + form_action,
            data:{
                id:id,
                title:title,
                author:author,
                published_date:published_date
            }
        }).done(function(data){
            // Reset Form
            $("#title_edit").val('');
            $("#author_edit").val('');
            $("#published_date_edit").val('');

            // Display new item on the list
            displayPageEntries();

            // Hide modal
            $("#edit-book").modal('hide');
            toastr.success('Item Updated Successfully.', 'Success Alert', {timeOut: 5000});
        });
    }else{
        alert('All fields are required. Please make sure you fill out all fields correctly.')
    }

});

/* Delete book */
$("body").on("click",".delete-book",function(){
    var id = $(this).parent("td").data('id');
    $.ajax({
        dataType: 'json',
        type:'POST',
        url: url + 'api/delete.php',
        data:{ id:id }
    }).done(function(data){
        displayPageEntries();
        toastr.success('Item Deleted Successfully.', 'Success Alert', {timeOut: 5000});
    });
});

/* Display initial list of all books with pagination */
function displayBookList() {
    $.ajax({
        dataType: 'json',
        url: url+'api/index.php',
        data: {page:page}
    }).done(function(data){
    	total_page = Math.ceil(data.total/display_rows);
    	current_page = page;
    	refreshList(data.data);


        $('#pagination').twbsPagination({
	        totalPages: total_page,
	        visiblePages: current_page,
	        onPageClick: function (event, pageL) {
	        	page = pageL;

                    displayPageEntries();

	        }
	    });

    });
}

/* Display books for current page*/
function displayPageEntries() {
	$.ajax({
    	dataType: 'json',
    	url: url+'api/index.php',
    	data: {page:page}
	}).done(function(data){
		refreshList(data.data);
	});
}

/* Refresh table list  */
function refreshList(data) {
	var	rows = '';
	$.each(data,function(key,value) {
	  	rows = rows + '&lt;tr&gt;';
	  	rows = rows + '&lt;td&gt;'+value.published_date+'&lt;/td&gt;';
	  	rows = rows + '&lt;td&gt;'+value.author+'&lt;/td&gt;';
        rows = rows + '&lt;td&gt;'+value.title+'&lt;/td&gt;';
	  	rows = rows + '&lt;td data-id="'+value.id+'"&gt;';
        rows = rows + '&lt;button data-toggle="modal" data-target="#view-book" class="btn btn-primary btn-sm view-book"&gt;View Details&lt;/button&gt; ';
        rows = rows + '&lt;button data-toggle="modal" data-target="#edit-book" class="btn btn-primary btn-sm edit-book"&gt;Edit Book&lt;/button&gt; ';
        rows = rows + '&lt;button class="btn btn-danger btn-sm delete-book"&gt;Delete&lt;/button&gt;';
        rows = rows + '&lt;/td&gt;';
	  	rows = rows + '&lt;/tr&gt;';
	});
	$("tbody").html(rows);
}

});</pre>
<p style="text-align: center;"><a class="button" href="http://projects.chiefofstack.com/ajax-crud/" target="_blank" rel="noopener noreferrer">LAUNCH TEST PROJECT</a></p>
<p>I grouped it into 4 basic steps to make the process of building the app more straight forward. On this test project without using a proper MVC framework (using only PHP, mySQL and jQuery) we have completed an AJAX CRUD app complete with notification and pagination.</p>
<p>This is important because there will be times that a programmer will be limited by the technology he can use and that’s when it pays to know the basics. I hope you enjoyed this tutorial, please share it to someone who might need it. Thanks!</p>
<p> </p>

		</div>
	</div>
</div></div></div></div><p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2021/01/23/basic-ajax-crud-app-using-php-mysql-and-jquery/">Basic AJAX CRUD app using PHP, MySQL and jQuery</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.chiefofstack.com/2021/01/23/basic-ajax-crud-app-using-php-mysql-and-jquery/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Improving site speed: Time to First Byte (TTFB)</title>
		<link>https://www.chiefofstack.com/2020/09/22/improving-site-speed-time-to-first-byte-ttfb/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=improving-site-speed-time-to-first-byte-ttfb</link>
					<comments>https://www.chiefofstack.com/2020/09/22/improving-site-speed-time-to-first-byte-ttfb/#respond</comments>
		
		<dc:creator><![CDATA[Jay Acab]]></dc:creator>
		<pubDate>Tue, 22 Sep 2020 03:58:31 +0000</pubDate>
				<category><![CDATA[Laravel]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.chiefofstack.com/?p=2654</guid>

					<description><![CDATA[<p>More than half of visits are abandoned if a page doesn&#8217;t load within 3 seconds, this translates to a huge loss in potential sales and leaves a bad impression to users. Speed is now also... </p>
<p class="more"><a class="more-link" href="https://www.chiefofstack.com/2020/09/22/improving-site-speed-time-to-first-byte-ttfb/">Read More</a></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/09/22/improving-site-speed-time-to-first-byte-ttfb/">Improving site speed: Time to First Byte (TTFB)</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>More than half of visits are abandoned if a page doesn&#8217;t load within 3 seconds, this translates to a huge loss in potential sales and leaves a bad impression to users. Speed is now also a landing page factor for Google Search and though it cannot be proven that an improved Time to First Byte (TTFB) increases Page Rank, there is enough correlation to believe so. Take AMP pages, Google Search now favors AMP pages in their results. Accelerated Mobile Pages (AMP) are stripped down versions of HTML that makes loading on mobile devices faster. </p>



<p>So what really is TTFB? and what affects it?  TTFB  is the metric to focus on if you want to drastically improve your page load time, technically it is affected by these 3 things:</p>



<ol><li>The time it takes for your request to propagate through the network to the web server</li><li>The time it takes for the web server to process the request and generate the response</li><li>The time it takes for the response to propagate back through the network to your browser.</li></ol>



<figure class="wp-block-image size-large"><img loading="lazy" width="971" height="264" src="https://www.chiefofstack.com/wp-content/uploads/2020/09/ttfb-no-caching-no-cdn.jpg" alt="" class="wp-image-2675" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/09/ttfb-no-caching-no-cdn.jpg 971w, https://www.chiefofstack.com/wp-content/uploads/2020/09/ttfb-no-caching-no-cdn-300x82.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2020/09/ttfb-no-caching-no-cdn-768x209.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2020/09/ttfb-no-caching-no-cdn-550x150.jpg 550w" sizes="(max-width: 971px) 100vw, 971px" /><figcaption><em>DNS time, socket time, SSL time, redirect time, and backend processing took around 6 seconds</em></figcaption></figure>



<p>In layman&#8217;s term, it&#8217;s just the time when the first byte of the page arrive (after any redirects). You don&#8217;t want to look at a waterfall chart like the one above where the first 3 items took around 6 seconds. </p>



<p>As an engineer, you need to take care of 3 things to be able to improve TTFB: </p>



<ol><li>Proper use of a Content Delivery Network (CDN) to reduce latency</li><li>Use of dynamic cache or page cache to reduce server processing.</li><li>Compression and minification of web assets to decrease loading</li></ol>



<h4>Proper use of a CDN</h4>



<p>With a CDN you reduce the physical distance and the number of hops an asset take to reach its destination. For example, the user is from Manila and the server is in New York, a CDN server in between (say Singapore) can deliver a jpeg file faster than the actual server in New York. Cloudflare CDN saves static content to it&#8217;s network of servers around the world then serve those cached content from edge servers nearest the next visitor.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1081" height="766" src="https://i0.wp.com/www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules.png?fit=710%2C503&amp;ssl=1" alt="" class="wp-image-2665" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules.png 1081w, https://www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules-300x213.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules-1024x726.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules-768x544.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules-1060x751.png 1060w, https://www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules-550x390.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/09/cloudflare-page-rules-706x500.png 706w" sizes="(max-width: 1081px) 100vw, 1081px" /><figcaption><em>&#8220;Cache everything&#8221; page rule in Cloudflare</em></figcaption></figure>



<p>TIP: If you have a static site like a blog or a basic company website,  just use the &#8220;Cache everything&#8221; page rule in Cloudflare. Using that will greatly improve your TTFB even if you only use an economy web host because most requests will be served from the edge cache and won&#8217;t actually touch your server. Just make sure to add another page rule to bypass caching of admin and dynamic pages.</p>



<h4>Caching and Compression</h4>



<figure class="wp-block-image size-large"><img loading="lazy" width="830" height="380" src="https://www.chiefofstack.com/wp-content/uploads/2020/09/WP-fastest-cache-1.png" alt="" class="wp-image-2663" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/09/WP-fastest-cache-1.png 830w, https://www.chiefofstack.com/wp-content/uploads/2020/09/WP-fastest-cache-1-300x137.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/09/WP-fastest-cache-1-768x352.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/09/WP-fastest-cache-1-550x252.png 550w" sizes="(max-width: 830px) 100vw, 830px" /><figcaption><em>The WordPress Fastest Cache plugin saves pages in cache to reduce server processing time</em></figcaption></figure>



<p>Content Management Systems (CMS) generate pages on demand through the use of PHP and MySQL server requests. By using dynamic or file cache, commonly accessed pages can be stored in a file (or in memory) to reduce server processing time. You can think of it as the recent calls in your phone&#8217;s history, if you want to call someone again you don&#8217;t have to go through the trouble of finding that person in your phone book. </p>



<p>In Laravel, I simply run <code>npm run production </code> in my terminal and let Webpack take care of bundling the assets (minifying and compression) and then use my favorite package to cache pages. In WordPress, there&#8217;s a lot of plugins to cache pages (I regularly use WP Fastest Cache and WP Super cache plugins). I like WP Fastest Cache because it has options to minimize and compress CSS and JS files automatically. Whatever the framework is, the goal is always to reduce the time it takes for requests to reach users.</p>



<h4>Measuring TTFB</h4>



<figure class="wp-block-image size-large"><img loading="lazy" width="1126" height="871" src="https://i0.wp.com/www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test.jpg?fit=710%2C549&amp;ssl=1" alt="" class="wp-image-2667" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test.jpg 1126w, https://www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test-300x232.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test-1024x792.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test-768x594.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test-1060x820.jpg 1060w, https://www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test-550x425.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2020/09/Webpagetest.org-first-byte-test-646x500.jpg 646w" sizes="(max-width: 1126px) 100vw, 1126px" /><figcaption><em>This site&#8217;s results in webpagetest.org</em> <em>where the First Byte time is only 300ms.</em></figcaption></figure>



<p>To be able to improve your TTFB you have to be able to measure it properly. There are a number of tools to measure site speed and TTFB, one tool that I always use is WebPageTest.org. There you can place your site&#8217;s URL and test location (from where you want to simulate the speed) and in less than a minute you will get a detailed waterfall of all resources being loaded on a page.</p>



<p></p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/09/22/improving-site-speed-time-to-first-byte-ttfb/">Improving site speed: Time to First Byte (TTFB)</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.chiefofstack.com/2020/09/22/improving-site-speed-time-to-first-byte-ttfb/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Tips to make working from home a success during and post pandemic</title>
		<link>https://www.chiefofstack.com/2020/07/07/tips-to-make-working-from-home-a-success-during-and-post-pandemic/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=tips-to-make-working-from-home-a-success-during-and-post-pandemic</link>
					<comments>https://www.chiefofstack.com/2020/07/07/tips-to-make-working-from-home-a-success-during-and-post-pandemic/#respond</comments>
		
		<dc:creator><![CDATA[Jay Acab]]></dc:creator>
		<pubDate>Tue, 07 Jul 2020 00:09:33 +0000</pubDate>
				<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.chiefofstack.com/?p=2636</guid>

					<description><![CDATA[<p>On our first AIM-DBI program orientation we were asked what we do to keep ourselves sane during the quarantine, I answered the usual &#8211; exercise, playing the guitar and bingeing on Netflix. But then I... </p>
<p class="more"><a class="more-link" href="https://www.chiefofstack.com/2020/07/07/tips-to-make-working-from-home-a-success-during-and-post-pandemic/">Read More</a></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/07/07/tips-to-make-working-from-home-a-success-during-and-post-pandemic/">Tips to make working from home a success during and post pandemic</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>On our first AIM-DBI program orientation we were asked what we do to keep ourselves sane during the quarantine, I answered the usual &#8211; exercise, playing the guitar and bingeing on Netflix. But then I realized, not much has really changed in my routine during the lock-down. I mean, I&#8217;ve been doing this (work from home) for the most part of my professional career that I subconsciously structured my life in a way that I can be successful and well for the most part.. sane.</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="666" src="https://www.chiefofstack.com/wp-content/uploads/2020/07/digest-aim-dbi-thincohort-orientation-2020-1024x666.jpg" alt="" class="wp-image-2639" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/07/digest-aim-dbi-thincohort-orientation-2020-1024x666.jpg 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/07/digest-aim-dbi-thincohort-orientation-2020-300x195.jpg 300w, https://www.chiefofstack.com/wp-content/uploads/2020/07/digest-aim-dbi-thincohort-orientation-2020-768x500.jpg 768w, https://www.chiefofstack.com/wp-content/uploads/2020/07/digest-aim-dbi-thincohort-orientation-2020-1060x690.jpg 1060w, https://www.chiefofstack.com/wp-content/uploads/2020/07/digest-aim-dbi-thincohort-orientation-2020-550x358.jpg 550w, https://www.chiefofstack.com/wp-content/uploads/2020/07/digest-aim-dbi-thincohort-orientation-2020.jpg 1280w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>AIM-DBI THINCOHORT  2020 ONLINE ORIENTATION</figcaption></figure>



<p>People think that working from home is straightforward,  how hard can it be, you just sit in front of the computer the whole day. Not gonna blame them though,  there&#8217;s a lot of &#8220;get rich quick &#8211; work from home&#8221; schemes out there, but make no mistake becoming a successful work from home professional is no easy feat. There&#8217;s a lot of hurdles to overcome. </p>



<p><strong>Have your own workspace</strong><br>Can be a room, a cubicle or just a desk, whatever it may be you should treat it as a &#8220;safe zone&#8221; where you are free from non-work related stuff. Maybe you have a kid who constantly nag you, or you share your room with your annoying sibling, or you probably work in your living room. No matter your situation, your workspace should be sacred. It&#8217;s your job to make sure that people around you know that. It&#8217;s your chapel, a place where you can think clearly, organize your thoughts and focus on your tasks.  No one should be able to disrupt your train of thought, you must impose restrictions, one example can be to require them to ask for your permission to talk to you (drastic but effective) when you are in your space.</p>



<p><strong>Get up and exercise</strong><br>Being active releases happy hormones and working happy is a success in itself. You will be more creative and it helps you think more clearly.  But not all physical activities are the same, just because you sweat doesn&#8217;t mean you are exercising (doing household chores doesn&#8217;t count). You have to dedicate an hour or two everyday for an actual exercise &#8211; bike, yoga, run or body weight training. Commit to a workout plan and soon you will see what a well maintained body does to your thoughts. Another benefit of being active is that it keeps you occupied hence no time for negativity. For me, it gives me time o think of all the positive things I want to accomplish.</p>



<p><strong>Read and learn new things</strong><br>Keep learning, your knowledge is your edge. Aside from being active physically you should strive to keep your mind active as well &#8211; reading books, attending online classes, watching tutorials are great ways to learn new things. Knowledgeable people more often than not give better solutions to client problems and guess what, your boss appreciate workers who have gumption to resolve their their problems. It also show to potential clients that you are open to continued learning if ever a need arise.</p>



<p><strong>Have a schedule.</strong><br>Have a schedule and follow it religiously. Repetition leads to success. Make your bed @ 6am, run @ 7am, it&#8217;s really up to you, completing a task however small it may seem gives you confidence to do the next one which will eventually carry over to your work and so on. But be careful not to overload your day, tweak it little by little to come up with something that works for you. Do, assess, revise, repeat.</p>



<p><strong>Backup Backup Backup.</strong><br>Have a cloud based backup and one or two external drives. Trust me, this is the best investment you can do for yourself. Better have copies laying around for when the time comes, it will save you tons of hours of work. There were several instances where I lost all my files because I was too complacent that my main machine won&#8217;t bug down and my drives won&#8217;t be stolen (yeah, burglar/s went in my apartment). I lost all my files and had to start everything from scratch. Have multiple backups, your future self will thank you for it.</p>



<p><strong>Secure your workspace</strong><br>Aside from software security you also have to deal with physically securing your laptop (whatever your main weapon is) and your backups. This may sound too cautious and that&#8217;s what I thought too until the burglar incident. They stole all of my laptops, my backups and in one day all of my life&#8217;s work were gone entirely. Remember, you are not working in an office environment where there&#8217;s 24/7 security, this is going to be your responsibility. Have a safe if needed.</p>



<p><strong>Legitimize your services</strong><br>It took me years before I finally decided to legitimize my online services but when I did there was no looking back. Aside from the prestige and benefits of having your own business,  all big companies require an official receipt in order to pay your compensation. In order to land big clients you have to be legit. Registering your service as a freelance professional was a complex endeavor, back then the requirements were for brick and mortar businesses, I was moving a lot so that was not really an option for me, but in the last 5 years it has became easier to register yourself as a professional. </p>



<p><strong>Strive for work life integration</strong><br>For me work life balance is overrated, it&#8217;s work life integration that we should be after. It&#8217;s not your regular 9 to 5 work day where you can clock out at 5 and leave work behind, you have to be able to come to work at 9, put it on hold for a while (to do private things) and get back an hour later to where you were, this happens several times a day until you are ready to call it a day. It can be weird at first, but integrating work as part of your life  is one of the key factors to become successful.  The saying &#8220;find a job you love and you&#8217;ll never work a day in your life&#8221; is applicable in this type of setup.</p>



<p>Working from home is a marathon not a sprint, just be patient, be consistent and have the courage to do the small things, pretty soon you will be doing amazing things! Good luck.</p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/07/07/tips-to-make-working-from-home-a-success-during-and-post-pandemic/">Tips to make working from home a success during and post pandemic</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.chiefofstack.com/2020/07/07/tips-to-make-working-from-home-a-success-during-and-post-pandemic/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Install PHP 7 and Composer on Windows 10 through  Ubuntu in WSL</title>
		<link>https://www.chiefofstack.com/2020/06/05/install-php-7-and-composer-on-windows-10-through-ubuntu-in-wsl/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=install-php-7-and-composer-on-windows-10-through-ubuntu-in-wsl</link>
					<comments>https://www.chiefofstack.com/2020/06/05/install-php-7-and-composer-on-windows-10-through-ubuntu-in-wsl/#respond</comments>
		
		<dc:creator><![CDATA[Jay Acab]]></dc:creator>
		<pubDate>Fri, 05 Jun 2020 20:01:15 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.chiefofstack.com/?p=2610</guid>

					<description><![CDATA[<p>A major advantage of using this setup over the more common XAMPP development environment is that with Ubuntu in WSL, the PHP 7 installation will be the 64 bit variant, as opposed to XAMPP where... </p>
<p class="more"><a class="more-link" href="https://www.chiefofstack.com/2020/06/05/install-php-7-and-composer-on-windows-10-through-ubuntu-in-wsl/">Read More</a></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/06/05/install-php-7-and-composer-on-windows-10-through-ubuntu-in-wsl/">Install PHP 7 and Composer on Windows 10 through  Ubuntu in WSL</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A major advantage of using this setup over the more common XAMPP development environment is that with Ubuntu in WSL, the PHP 7 installation will be the 64 bit variant, as opposed to XAMPP where PHP is only available at x86. Using 64bit PHP means more memory for running composer for big projects. </p>



<p>Recently one of our projects got too big and I encountered memory allocation error when I ran composer update. I did this as a workaround and fortunately there was no more issues after I&#8217;m done </p>



<p>I assume you already have WSL running on your machine, here are the steps I did to install Composer and PHP 7.0.</p>



<h2>Install PHP inside Ubuntu </h2>



<p>First update the package list. </p>



<p><code>$ sudo apt-get update</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1048" height="563" src="https://i0.wp.com/www.chiefofstack.com/wp-content/uploads/2020/06/Screenshot_1.png?fit=710%2C381&amp;ssl=1" alt="" class="wp-image-2612" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/06/Screenshot_1.png 1048w, https://www.chiefofstack.com/wp-content/uploads/2020/06/Screenshot_1-300x161.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/06/Screenshot_1-1024x550.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/06/Screenshot_1-768x413.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/06/Screenshot_1-550x295.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/06/Screenshot_1-931x500.png 931w" sizes="(max-width: 1048px) 100vw, 1048px" /></figure>



<p>Then just install php 7.0:  </p>



<p><code>$ sudo apt-get install -y php7.0</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1048" height="563" src="https://i1.wp.com/www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl.png?fit=710%2C381&amp;ssl=1" alt="" class="wp-image-2614" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl.png 1048w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl-300x161.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl-1024x550.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl-768x413.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl-550x295.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl-931x500.png 931w" sizes="(max-width: 1048px) 100vw, 1048px" /></figure>



<p>It may take a while to setup some stuff&#8230;</p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1048" height="563" src="https://i0.wp.com/www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl2.png?fit=710%2C381&amp;ssl=1" alt="" class="wp-image-2615" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl2.png 1048w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl2-300x161.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl2-1024x550.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl2-768x413.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl2-550x295.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-php-7-ubuntu-wsl2-931x500.png 931w" sizes="(max-width: 1048px) 100vw, 1048px" /></figure>



<p>If everything goes well PHP 7.0 will be installed. Verify it by simply running:  </p>



<p><code>$ php -v</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1048" height="563" src="https://i0.wp.com/www.chiefofstack.com/wp-content/uploads/2020/06/check-php-version.png?fit=710%2C381&amp;ssl=1" alt="" class="wp-image-2616" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/06/check-php-version.png 1048w, https://www.chiefofstack.com/wp-content/uploads/2020/06/check-php-version-300x161.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/06/check-php-version-1024x550.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/06/check-php-version-768x413.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/06/check-php-version-550x295.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/06/check-php-version-931x500.png 931w" sizes="(max-width: 1048px) 100vw, 1048px" /></figure>



<h2>Install Composer inside Ubuntu </h2>



<p>To install Composer we follow the official instructions <a rel="noreferrer noopener" href="https://getcomposer.org/download/" target="_blank">here</a>. Run the following commands:</p>



<p><code>$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"</code></p>



<pre class="wp-block-preformatted"><code>$ php -r "if (hash_file('sha384', 'composer-setup.php') === 'e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"</code></pre>



<p><code>php composer-setup.php</code></p>



<p><code>$ php -r "unlink('composer-setup.php');"</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1048" height="563" src="https://i0.wp.com/www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl.png?fit=710%2C381&amp;ssl=1" alt="" class="wp-image-2617" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl.png 1048w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl-300x161.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl-1024x550.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl-768x413.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl-550x295.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl-931x500.png 931w" sizes="(max-width: 1048px) 100vw, 1048px" /></figure>



<p>Composer is now installed! test it out by running. </p>



<p><code>$ php composer.phar</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1048" height="563" src="https://i2.wp.com/www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl3.png?fit=710%2C381&amp;ssl=1" alt="" class="wp-image-2618" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl3.png 1048w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl3-300x161.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl3-1024x550.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl3-768x413.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl3-550x295.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl3-931x500.png 931w" sizes="(max-width: 1048px) 100vw, 1048px" /></figure>



<p>You can optionally add composer to your global path to make to make it easier to use.   </p>



<p><code>sudo mv composer.phar /usr/local/bin/compose</code></p>



<figure class="wp-block-image size-large"><img loading="lazy" width="1048" height="563" src="https://i2.wp.com/www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl4.png?fit=710%2C381&amp;ssl=1" alt="" class="wp-image-2620" srcset="https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl4.png 1048w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl4-300x161.png 300w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl4-1024x550.png 1024w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl4-768x413.png 768w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl4-550x295.png 550w, https://www.chiefofstack.com/wp-content/uploads/2020/06/install-composer-ubuntu-wsl4-931x500.png 931w" sizes="(max-width: 1048px) 100vw, 1048px" /></figure>



<p>Windows Subsystem for Linux was made for developers and offers all the benefits that comes from using a dedicated Linux machine. With WSL you can run your favorite Windows apps and execute Linux commands natively just like how I installed PHP 7 and Composer inside Ubuntu on our Windows 10 PC. </p>



<p></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/06/05/install-php-7-and-composer-on-windows-10-through-ubuntu-in-wsl/">Install PHP 7 and Composer on Windows 10 through  Ubuntu in WSL</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.chiefofstack.com/2020/06/05/install-php-7-and-composer-on-windows-10-through-ubuntu-in-wsl/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>3 most essential principles of responsive design</title>
		<link>https://www.chiefofstack.com/2020/05/30/3-most-essential-principles-of-responsive-design/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=3-most-essential-principles-of-responsive-design</link>
					<comments>https://www.chiefofstack.com/2020/05/30/3-most-essential-principles-of-responsive-design/#respond</comments>
		
		<dc:creator><![CDATA[Jay Acab]]></dc:creator>
		<pubDate>Sat, 30 May 2020 17:41:48 +0000</pubDate>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">http://chiefofstack.jay/?p=2578</guid>

					<description><![CDATA[<p>Responsive web design is built on several principles to work properly. Below are the three most essential principles of a responsive website to get you started. Fluid grids Media queries Flexible images and media NOTE:... </p>
<p class="more"><a class="more-link" href="https://www.chiefofstack.com/2020/05/30/3-most-essential-principles-of-responsive-design/">Read More</a></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/05/30/3-most-essential-principles-of-responsive-design/">3 most essential principles of responsive design</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Responsive web design is built on several principles to work properly. Below are the three most essential principles of a responsive website to get you started.</p>



<ol><li>Fluid grids</li><li>Media queries</li><li>Flexible images and media</li></ol>



<p class="has-cyan-bluish-gray-color has-text-color"><em>NOTE: This article was originally posted at iStar&#8217;s blog, read the full article <a href="https://www.istarwebsolutions.com/web-design/3-most-essential-principles-of-responsive-design/" target="_blank" rel="noreferrer noopener">here</a></em></p>



<p><strong>Fluid Grids</strong>&nbsp;– Old websites were based on print media like newspapers and magazines. Columns were positioned and displayed in absolute size and position (pixels). Mobile devices changed all this, instead of solely relying on pixels for measurement, responsive design incorporated percentages to the mix to accommodate the growing number of resolutions.&nbsp;Fluid grids or “flexible grid” is the backbone of responsive design. It uses relative sizing to fit content to the device’s screen size. The grids are based on percentages. By basing text size, widths, and margins on percentages, a fixed size can be turned into a size relative to its display space.&nbsp;The name is a little misleading because a grid is not the only thing that makes it flexible, it relies on CSS to position the content.</p>



<p><strong>Media Queries</strong>&nbsp;–&nbsp;Also known as breakpoints, it can be used to apply different styles based on what the screen can handle. The website detects the type of device you’re using (resolution/viewport) and correctly displays the content. This can be observed by resizing your desktop browser to different sizes, you will notice how a responsive site adjusts to best display the content. It can be customized to control the width, height, max-width, max-height, device-height, orientation, aspect ratio, etc.</p>



<p><strong>Flexible images and media</strong>&nbsp;– Aside from the layout and text, images also needs to respond correctly. This&nbsp;allows your images and other media to load differently for every resolution. It can be achieved through scaling(CSS max-width) or cropping (CSS overflow property).&nbsp;With scaling the media element’s max width can be set at 100 percent so the browser will make it shrink or expand depending on the container. Cropping on the other hand hides portion of the image and still fit it to the container.</p>



<p>There are other things that come into play with responsive design, the above items will get you started and is enough if you know what you are doing. If you would like assistance regarding responsive design or if you are interested with any of our services, please don’t hesitate to contact us, our programmers are always ready to help.</p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/05/30/3-most-essential-principles-of-responsive-design/">3 most essential principles of responsive design</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.chiefofstack.com/2020/05/30/3-most-essential-principles-of-responsive-design/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Top 5 characteristics of an effective website</title>
		<link>https://www.chiefofstack.com/2020/05/30/top-5-characteristics-of-an-effective-website/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=top-5-characteristics-of-an-effective-website</link>
					<comments>https://www.chiefofstack.com/2020/05/30/top-5-characteristics-of-an-effective-website/#respond</comments>
		
		<dc:creator><![CDATA[Jay Acab]]></dc:creator>
		<pubDate>Sat, 30 May 2020 17:36:47 +0000</pubDate>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">http://chiefofstack.jay/?p=2571</guid>

					<description><![CDATA[<p>No one visits your website just to read your company’s mission and vision. Gone are the days when you only had to write your business objectives, add your company picture and call it a website.... </p>
<p class="more"><a class="more-link" href="https://www.chiefofstack.com/2020/05/30/top-5-characteristics-of-an-effective-website/">Read More</a></p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/05/30/top-5-characteristics-of-an-effective-website/">Top 5 characteristics of an effective website</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>No one visits your website just to read your company’s mission and vision. Gone are the days when you only had to write your business objectives, add your company picture and call it a website. Nowadays, millenials are expecting more.</p>



<p class="has-cyan-bluish-gray-color has-text-color"><em>NOTE: This article was originally posted at iStar&#8217;s blog, read the full article <a href="https://www.istarwebsolutions.com/web-design/top-5-characteristics-of-an-effective-website/" target="_blank" rel="noreferrer noopener">here</a></em></p>



<p>Aside from the usual interactivity, usability and social media integration, here are the top 5 basic characteristics your website must have in order to accommodate today’s users.</p>



<ol><li><strong>Fast loading speed</strong>&nbsp;– Your website needs to load fast. Yeah, call me captain obvious but there is actually a science behind this. Study shows that it takes an average of 3 seconds for a user to scan your page. The user must be able to reach the information he came for within said period so he can decide whether to stay or go. Test your user’s patience and say goodbye to a potential client. A good way to enhance speed is by lazy loading images found below the fold so elements at the top load faster.</li><li><strong>Well Formatted Content</strong>&nbsp;– Your design is important but nowadays (as it should) content is king. A user may take his business elsewhere if he can’t easily reach the information he came for. Consider putting your most important content above the fold to make it easily scan-able.</li><li><strong>Mobile compatibility / Mobile first</strong>&nbsp;– Google now ranks mobile first websites higher in search rankings. Mobile usage has eclipsed desktop this past few years and there is a good chance your potential client is using mobile exclusively. Your website must be responsive to be able to accommodate a wide range of mobile devices. See this previous post about responsive design [link to responsive website article]</li><li><strong>Cross browser compatibility</strong>&nbsp;– With each new browser version come a new interpretation of html/css. For example, back in the old days a transparency effect will be rendered by Firefox and Chrome but will need a different set of code for IE. Modern browsers had come a long way in making sure they comply with standards, which made the browsing experience somewhat consistent across all browsers. However there are still some quirks that may affect your website. Why browsers render differently is a question for the ages, it’s up to you to adapt. Your website must show consistency on all browsers, a line of text on one browser should also render properly on other browsers. That way a potential client can read your information no matter what browser he is using. It’s a delicate balance between features and compatibility, it is recommended to select features that you know is consistent across all browsers.</li><li><strong>Easy to use forms</strong>&nbsp;– Forms are essential on any business websites. It is the main area where users interact with the site and usually where leads come from. Make sure to make your forms easy to use and accessible. Add tooltips and suggestions on important fields if possible, limit the total number of fields and most importantly assign a label for all the fields.</li></ol>



<p>Ensuring your website is effective in delivering content on all types of devices improves your chances of getting a lead to potential clients. Your website is the face of your company and you need to make sure it’s engaging to prevent users from leaving, you did a lot of marketing to get them there, and your next goal should be to get them to stay. Following the above can help make your online presence a success.</p>
<p>The post <a rel="nofollow" href="https://www.chiefofstack.com/2020/05/30/top-5-characteristics-of-an-effective-website/">Top 5 characteristics of an effective website</a> appeared first on <a rel="nofollow" href="https://www.chiefofstack.com">Chief of Stack</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.chiefofstack.com/2020/05/30/top-5-characteristics-of-an-effective-website/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
