Why I still use PHP in 2019 and why you should too.

Why I still use PHP in 2019 and why you should too.

Let's clear the air quickly. I know PHP isn't the fastest language ever. I know it's syntactically ugly and doesn't provide much sugar. I also know it's one of the most hated languages, but I LOVE IT.

Let's clear the air quickly. I know PHP isn't the fastest language ever. I know it's syntactically ugly and doesn't provide much sugar. I also know it's one of the most hated languages, but I LOVE IT.

Some of the greatest websites and platforms where written with PHP. Mark Zuckerberg wrote Facebook with PHP. WordPress, which is currently running on over 1 million different domains according to WhatCMS, was originally and still is written in PHP. There’s also frameworks like Laravel, the most starred back-end framework on GitHub, is written in PHP.

Doesn’t that go to show you the popularity of PHP and how it has affected developers, and in some cases everyone?

Enough of the blabbering on. Why do I love PHP? Why should you still be using it in 2019? Here’s why.

PHP works so well with HTML

Despite most things being dynamically rendered with JavaScript frameworks these days, using HTML is still a thing. Maybe you don’t need to build an API to get data from the server - instead, you might already have the variable inside of a PHP file and want to variably output a title, depending on that variables state.

Something like this is so simple to do with PHP. You can use the alternative syntax for an if statement, put your HTML in and Bob’s your uncle.

For real though, the fact that you can convert any valid HTML file to a PHP file by simply changing the file extension is just so simple.

One thing to watch out for here though is novice programmers. I personally believe that one of the reasons people hate on PHP so much is due to the poor code that is written in these scenarios. When new programmers are learning PHP, they tend to have one huge lump of code before the HTML to prep the server related stuff, then throw it all together inside of the HTML. If you know what you’re doing, you can effectively separate your logic into a separate file and use a view file to do the front-end stuff.

The community is huge.

PHP has been around for a long time. This long life has created an extremely large community of PHP developers, some of which are OG’s and know what PHP really stands for (don’t be a faker and Google it).

This community is so useful. You’re experiencing a problem so you search the Internet for a solution. 9 times out of 10, someone else has had this problem before, found a solution and posted it on StackOverflow or another forum. If you can’t find an answer, ask the question yourself. The community is so big on these forum platforms that you’re bound to get multiple different answers, each giving you a different solution that boils down to the same outcome.

Not only is it good for problem solving and troubleshooting, but the amount of open source libraries, utilities and resources is forever growing. Maybe you don’t want to write a custom server-side router from scratch. Do not fear, as the dozens of repositories on GitHub are here.

Again, be aware of the community. It can get toxic, it can provide misleading information and will, at some point, provide poor code. It’s much like the previous point really.

Composer

You’ve probably used NPM in JavaScript, or Gems with Ruby. Well let me talk about Composer (and Packagist), because without it, I think PHP would be in a very different place today.

In the past, before Composer, when you wanted to use someone else’s code you would download the files, place them inside of a lib or vendor directory, manually include them or have to manually add them to your custom autoload functions. This is just a nightmare.

With Composer, it’s a completely different story. You find a cool library, it’s probably on Packagist. Inside of your project, just run a composer require / and you’ve got the files inside of your project. You can manage the versions, update them with a command and it just works. You don’t even have to include each file you want to use. Just require one file in your main file, use PHP’s use keyword to import the class and use it as you wish. How great is that?

As well as this, you don’t need to write tedious __autoload() or spl_register_autoload() functions anymore, because you can define an autoload scheme inside of a single JSON file, run a command and you have an auto loader created for your project.

It’s bliss. It’s beautiful. I love it.

It’s still growing.

To this day, PHP is still getting new features in each release. With PHP 7 we saw extremely impressive performance increases and new versions are being released on a schedule. Soon, we’ll have better support for type hinting (specifically class properties) and will continue to get improved array methods.

I’m interested to know what you think. Leave a comment below, tell me your opinions on PHP. Do you use it? Have you used it? Would you consider learning it?

Also, shameless self plug alert. I have just created a new Twitter account. You can find the link on my profile, or click here. I’ll tweet on there when I upload a new post on here. I’ll probably rant some too.

Thanks for reading ✌️

================================================

Thanks for reading :heart: If you liked this post, share it with all of your programming buddies! Follow me on Facebook | Twitter

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

What’s new in HTML6

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Clear Cache in Laravel 6.8 App using Artisan Command Interface (CLI)

Clear Cache in Laravel 6.8 App using Artisan Command Interface (CLI)

In Laravel 6 tutorial, we learn how to use PHP artisan command interface (CLI) to clear the cache from Laravel 6.8 application. How To Clear Cache in Laravel 6.8 Application using Artisan Command Line Interface (CLI)? How to clear route cache using php artisan command? How to easily clear cache in Laravel application? How to clear config cache in PHP Laravel via artisan command? How to clear Laravel view cache? How to Reoptimized class in Laravel via artisan CLI?

Today in this tutorial, we are going to learn how to clear route cache, laravel application cache, config cache, view cache and reoptimized class in a Laravel 6.8 application using artisan command-line interface.

I’m pretty sure many of you may have found yourself gotten into the situation where you do not see changes in the view after making the changes in the app.

Laravel application serves the cached data so caching problem occurs due to the robust cache mechanism of Laravel.

But, if you are still facing this issue, then you do not have to worry further. Let me do the honour of introducing you some of the best artisan commands to remove the cache from your Laravel app via PHP artisan command line interface.

Artisan is the command-line interface included with Laravel. It provides a number of helpful commands that can assist you while you build your application.

Table of Contents

  • Clear Route Cache in Laravel
  • Clear Laravel Application Cache
  • Clear Config Cache via PHP Artisan
  • Clear Laravel View Cache
  • Reoptimized Class
Clear Route Cache in Laravel

Laravel caching system also takes routes in consideration, to remove route cache in Laravel use the given below command:

php artisan route:cache
Clear Application Cache in Laravel

Run the following command to clear application cache:

php artisan cache:clear
Clear Config Cache in Laravel

Run the following command to clear config cache:

php artisan config:cache
Clear View Cache in Laravel

Run the following command to clean your view cache:

php artisan view:clear
Reoptimize Class

Run the below command to reoptimize the class loader:

php artisan optimize

Conclusion

We have completed this Laravel 6 tutorial, In this tutorial we learned how to use php artisan command to clear the cache from your Laravel application. We have answered the following questions in this article.

  • How to clear route cache using php artisan command?
  • How to easily clear cache in Laravel application?
  • How to clear config cache in PHP Laravel via artisan command?
  • How to clear Laravel view cache?
  • How to Reoptimized class in Laravel via artisan CLI?

Now, it’s your time to let me know what do you think about this laravel 6 article. Go forth and try these super awesome artisan commands and let me know how these commands are helping you.

Get Weather Data with Laravel Weather

Get Weather Data with Laravel Weather

Get Weather Data with Laravel Weather. Laravel Weather is a good package which we can use to get weather data. It's a wrapper around Open Weather Map API (Current weather). A wrapper around Open Weather Map API (Current weather)

🌤️ A wrapper around Open Weather Map API (Current weather)

Installation

You can install the package via composer:

source-shell
composer require gnahotelsolutions/laravel-weather
Usage
text-html-php
$weather = new Weather();

// Checking weather by city name
$currentWeatherInGirona = $weather->get('girona,es');

// You can use the city id, this will get you unambiguous results
$currentWeatherInGirona = $weather->find('3121456');

Units

By default the package uses metric for Celsius temperature results, this can be modified using the configuration file or on the fly:

text-html-php
$weather = new Weather();

$currentWeatherInGirona = $weather->inUnits('imperial')->get('girona,es');

Language

By default the package uses es for the description translation, this can be modified using the configuration file or on the fly:

text-html-php
$weather = new Weather();

$currentWeatherInGirona = $weather->inLanguage('en')->get('girona');

Guzzle Client Instance

If you need to use another instance of Guzzle, to modify headers for example:

text-html-php
$weather = new Weather();

$guzzle = $this->getSpecialGuzzleClient();

$currentWeatherInGirona = $weather->using($guzzle)->get('girona');

Testing

source-shell
composer test

Laravel Sweet Alert | How to use the SweetAlert package in Laravel PHP

Laravel Sweet Alert | How to use the SweetAlert package in Laravel PHP

Sweet Alert is a laravel wrapper around #sweetalert javascript library for showing alert or notification message. This is a great package created by rashid, and this laravel package is very famous because it has tonnes of features you can choose from.

Sweet Alert is a laravel wrapper around #sweetalert javascript library for showing alert or notification message.

This is a great package created by rashid, and this laravel package is very famous because it has tonnes of features you can choose from.