The KoolReport Blog

Announcements, discussions, and more for KoolReport and its extended packages.

PHP 7.4: Top 5 Advanced Features That You Need To Know

PHP 7.4 has been released in Nov 28th, 2019 with new syntax and significant performance enhancement. Let look at the top 5 cool features of PHP 7.4 that you should know.

PHP 7.4 Top 5 advanced features

Since PHP7, we have seen the incredible changes in PHP from its syntax improvement to its speed and efficiency. Since the emergence of new language like NodeJS, GoLang, there are always rumor whether PHP is going to die but believe me PHP still move forward and be stronger day by day. It is no wonder that for the second year in a row, PHP is among the top 10 most popular programming languages according to StackOverflow Developer Survey 2019. This year, it took the 8th place which is one rank higher than in the previous year.

PHP 7.4 has been released in Nov 28th, 2019 with new syntax and significant performance enhancement. Let look at the most top 5 cool features of PHP 7.4 that you need to know. Let started!

Arrow function

If you are using ES6 in Javascript, probably you have been familiar with arrow function. The arrow function helps to reduce syntax when we write anonymous functions. So now instead of writing this:

function do_double($n)
{
    return $n*$n;
}
$a = [1,2,3];
$b = array_map("do_double",$a);

With PHP 7.4, you can do:

$a = [1,2,3];
$b = array_map(fn($n) => $n*$n, $a);

As a result, your code will look cleaner & neater, allowing you to save much development & debugging time.

Typed properties

This new feature is considered one of the most important features in PHP 7.4. Previously you need to use getter and setter in order to check types of variables. Now you can easily specify type for class's variables:

class SaleReport
{
    protected int $month;
}

Due to declaration types (excluding void and callable), you can use nullable types, int, float, array, string, object, iterable, self, bool, and parent.

If developer try to assign irrelevant value from the type, he or she will get TypeError message.

The same like arrow function, typed properties will reduce work for developer and make code cleaner and shorter.

Preloading

Finally, preloading is supported in PHP, which will help to improve performance. As you may know, each time you page is requested, the code files will need to read and loaded into memory to execute. Preloading, in simple word is process of loading code files into OPcache to execute faster. It will eliminate I/O process which consume time and resource, hence your page will response quickly.

When you use OPcache, the executed files will be first loaded into memory and will be checked for changes for next time. Preloading will let developer specify certain files to be loaded into memory and stay there. It will help to save time for OPcache to check changes in those files, thus, increase the performance.

PHP 7.4 Preloading performance comparison

It is also noteworthy to mention that during preloading, PHP also eliminates needless includes and resolves class dependencies and links with traits, interfaces, and more.

Covariant & Contravariant

At the moment, PHP has mostly invariant parameter types and invariant return types which presents some constraints. With the introduction of covariant (types are ordered from more specific to more generic) returns and contravariant (types are ordered from more generic to more specific) parameters, PHP developers will be able to change the parameter’s type to one of its supertypes. The returned type, in turn, can be easily replaced by its subtype.

Coalescing assign operator

Below are the most common code that you will see in almost all projects:

$country = isset($_GET['country']) ? $_GET['country'] : 'unknown';

With PHP 7.4, now you can do:

$country = $_GET['country'] ?? 'unknown';

or a little complicated, you can do:

$country = $_GET['country'] ?? $_POST['country'] ?? 'unknown';

A spread operator

Another interesting feature in PHP 7.4 is the spread operator in array. Previously, you may need to use array_merge() to complete in complicated way. But no more, you can do this in PHP 7.4.

$parts = ['apple', 'pear'];
$fruits = ['banana', 'orange', ...$parts, 'watermelon'];

As you notice the ..., the array $part will be spread at right place in $fruits array. This is another feature that help developer to produce cleaner code and also save time on debugging.

Conclusion

There are several other updates in PHP 7.4 that we have not covered yet. Above are the features that we think the most important and that we need to know. As you may be aware that we are working on KoolReport, an PHP framework specializing in data report so keeping update with new features of PHP is a must for us. By utilizing new PHP features, we can improve the way data report should be created and ultimately make developer's life easier.

php

KoolReport 4.5.1 has been released!

We are happy to announce that we have released KoolReport core version 4.5.1 with new features. The KoolReport Pro also reaches same version number 4.5.1 with the new core update and the upgrade of individual packages such as Excel, Inputs, D3, ChartJs.

KoolReport's class

KoolReport's class is provided with new getXml() method to get the representation of your report in xml format. The xml contains both data and meta data of all report's datastores.

DataStore

In this version, we continue to enrich methods of datastore. DataStore has a new method called distinct(). As the name suggested, distinct method will have you to get a list of unrepeated values from a column. Furthermore, Datastore is provided with new toArray() and toJson() methods to get array and JSON. This could be useful if you need result in array form for further processing or JSON format to be returned in your REST API.

New DataSource

We have added new DataSource called ExistedPdoDataSource to handle source in case you only have the PDO object but connection settings. So you only need to send your existed PDO object as parameter to your report and provide it with ExistedPdoDataSource in settings() method.

JsonSpread process

JsonSpread is a new processed added to KoolReport in order to spread JSON data into column in data stream. By doing so, we are able to apply other KoolReport's processes to further process the JSON data.

Support CI/CD process

Since the popularity of CI/CD process, KoolReport library now fully support this new type of software integration and delivery processes. We understand the 1 hour token availability causes trouble for the automation delivery so we have increases the life time of token to maximum. In particular, the token will last until your subscription of KoolReport Pro is ended. If you have purchase the Perpetual Usage, the token expiration will be set the 2100-01-01 which is virtually life-time or never expired.

Support load balancing

If you are using load balancing with multiple servers containing app (with KoolReport integrated), the generated resource folders now have same name in all servers. So virtually, the client-side will be able to receive resource files regardless of servers it connects to.

D3Chart Client Events

The D3 chart has been upgraded with one of the most crucial features: client events. This is the missing part in D3 first version. Now all charts support itemSelect event which help you to track the click of user to item on the charts. Now D3 is able to work with DrillDown package to provide interactive drill down report.

DrillDown supports D3

Missing client events hindered the collaboration of DrillDown package with D3 chart. But not anymore, since the D3 package has supported the client events, the DrillDown package also support generate D3 Chart. By specifying the D3 chart as drilldown widgets, the DrillDown will bind itself to D3 itemSelect to provide interactive report.

Excel Package

We have fixed the PieChart display in Microsoft Excel and a minor bugs happened when data is missing.

ChartJS Package

We have upgraded the core of ChartJS to latest version of 2.9.x. With this new upgrade, some of known issues has been addressed. Furthermore, we have provided new plugins property which allows you to use most popular plugins for ChartJS like datalabels, annotation, stacked100 and others.

Inputs Package

Due to the upgrade of FontAwesome library in previous KoolReport's version, some of the icons have not been displayed correctly. This issue has been addressed in this new version of Inputs package.

New Yii2 Package

In this release, we roll out new package koolreport\yii2. As the name suggested, yii2 package will facilitate the integration of KoolReport with Yii2, one of the most used frameworks in PHP. Similar to other integration packages that we have created before like laravel or codeigniter, the yii2 package will help to auto configure report's assets settings and allow report to access to default database connection setup within Yii2.

Summary

The version 4.5.x added new features and empowered reporting capability to KoolReport. This upgrade is backward compatible with old 4.x versions so feel free to upgrade. If you need have any question about this new release, do not hesitate to let us know.

Thank you!

<3 koolreport team

PHP Dies Or Not?

PHP has had better days, for sure. But is it really dead? On a forums like Stack Overflow people are suggesting that PHP is dead. Do they have a valid point, or could it be that they just don’t like PHP? Let’s take a look at PHP and see if there is a future for this programming language.

PHP Is Still Dominating The Web

If you take a simple look at the numbers PHP is definitely not dead. PHP is the most used server-side programming language by far. Approximately 75 percent of all webpages are powered by PHP. It is fair to conclude that PHP isn’t dead based on this statistic since 75 percent is far too high number for a dead language!

One of the reasons that PHP is used by so many websites is because WordPress uses PHP. The market share of WordPress is approximately 34 percent of all websites. That’s 75 million websites using WordPress. Furthermore, there are some other CMS’s like Drupal (3%) and Joomla(2%) which also have a significant share of the market. And there are some popular shop management systems, like Magento, which have around 1 percent of the total market share.

A lot of big content and shop management systems are using PHP, which makes PHP important and relevant.

Building Websites From Scratch

I can see the argument about building websites from scratch since a lot of people, who use WordPress for example, don’t know how to code. Making a website in WordPress does not require you to know how to code. A lot of people who have a WordPress website probably don’t even know that it’s powered by PHP. So is PHP still used by people who build websites from scratch?

PHP was and still is a very popular language. One of the reasons for this is that it’s a really easy programming language to learn. That makes it an excellent language for people new to building websites. PHP can be learned without any prior knowledge. I think it’s fair to say that most web developers that have been around for a while probably started out with PHP, or at least have worked with PHP at some point.

Programming

Since PHP has been around since 1994 the language has got a little cluttered over time. There are a lot of ways to build the same functionality and a lot of these ways are pretty hacky. This makes it easier to write bad code in PHP. Obviously, it’s possible to write bad code in any language but PHP makes it a little easier because of the way it has grown.

PHP has been around so long it also has a lot of old stuff. This makes it easy to get started with PHP, but if you stick to the old solution you end up with suboptimal code that doesn’t follow best practices. And this is something that you should really try to avoid. Not following the best practice is something that will happen when you’re inexperienced with PHP since it is not always clear what the best solution is. This is because there are a lot of ways to solve the same problem. This is one of the reasons why PHP is hated by some developers.

On the other hand, you could argue that most web developers don’t write raw PHP. Most of the times you will be using some sort of framework that does a lot of things for you. A popular PHP framework that is very clean is Laravel. The advantage of working with a framework is that a lot of the dirty work is done under the hood. The framework forces you into writing cleaner code.

PHP 7

Since the release of PHP 7 a lot of new features and improvements have been introduced. The two most significant improvements are improved speed and better memory usage. This means that websites that use PHP 7 load faster than websites that use an older version of PHP and can handle more users at the same time.

Code wise, type declarations and new operators have been introduced. Error handling has also been improved.

Jobs

Since 75 percent of the web is powered by PHP there will obviously be a lot of jobs involving some sort of PHP coding. All these websites need to be maintained and there are PHP developers needed for that. The enormous market share of PHP won’t be gone overnight, so jobs involving PHP will be around in the future.

If you take a look at this link to the jobs section of Stack Overflow you will find a lot of jobs that require PHP.

Conclusion

Although there is a lot of discussion about the future of PHP, it is clear that PHP does have a future. It is by far the most used programming language for websites.

PHP has been around for a while now and this is reflected in the code. There’s a lot of old stuff that means the best solution is not always clear. Code wise you could use a framework that does a lot of the dirty work for you and forces you to write cleaner code. However, since the introduction of PHP 7, a lot of things have improved.

If you want to start a career as a PHP developer you won’t run out of options when it comes to finding a job. There are plenty of jobs involving PHP skills and this will stay the same in the near future. So what do you think about PHP? Do you think there is a future for this programming language? Or is it dead?

Thanks for reading!

<3 koolreport team

KoolReport 4.3.0 has been released!

We would like to inform that we have released new version KoolReport 4.3.0 ready for your upgrade. This is a worth upgrading version containing many improvements and important bug fixes.

Details

For further details of the changes in this new version, please follow these links:

This upgrade is backward compatible so feel free to upgrade now!

Some more good news

On further update, we have released a new chart package called D3. The package is built on top of D3JS (Data-Driven Documents) to provide visualization strength for KoolReport. D3JS is very famous Javascript library which is behind many beautiful charts and graphs. Except for the most common charts like Line or Pie, we have added Waterfall and FunnelChart to extend choices for your data visualization. IT IS JUST THE BEGINNING! More and more stunning charts will be added to D3 package.

KoolReport Pro 4.3.1 has been released as well with new core and the upgrades of 14 packages including Pivot, DataGrid, Export and more.. If you have KoolReport Pro license, you may upgrade now via manual download or composer installation. If you have not owned a license yet, please consider to get one now. You will love it!

P.S: KoolReport team wish you have a great day and do not forget to support us. We are and will work hard to bring you to best product saving you time & effort. That's our promise.

<koolreport team

Stunning Data Reports Made Easy! 20% OFF For KoolReport Pro

Building great data reports has never been easier with KoolReport Pro. Equipped with all commercial packages, KoolReport Pro will power your creativity to make stunning reports and dashboards.

Click here to get KoolReport Pro with 20% OFF, ends soon on 31st August, 2019

On this occasion, we offer a special discount 20% for both Developer License and Enterprise License. This promotion will last until 31st AUGUST, 2019.

PURCHASE NOW WITH 20% OFF!

If you have any question regarding our promotion or features of KoolReport Pro, please do not hesitate to contact us.

Looking forward to serving you as our customer.

<3 koolreport team


KoolReport helps to analyze your data and ultimately turn them into visual reports or dynamic dashboards.

"KoolReport helps me very much in creating data report for my corporate! Keep up your good work!"

Alain Melsens

"The first use of your product. I was impressed by its easiness and powerfulness. This product is a great product and amazing."

Dr. Lew Choy Onn

"Fantastic framework for reporting!"

Greg Schneider
Get KoolReport Now, It's FREE!