Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Ben Sampson:
Speed up relationship queries in Laravel
Aug 07, 2018 @ 16:51:40

Ben Sampson has a tutorial posted to his site for the Laravel users out there sharing some tips about speeding up your database queries when using relationships between models.

Adding indexes to your database tables is a great way to get some extra performance out of your application, especially if you have a large amount of data in your tables. They should be used sparingly and only on identified slow queries, as they have implications of their own such as increased table size and increased RAM usage. But those potential drawbacks are well worth it when you can get a query down from a 3 seconds 15 milliseconds with 5 minutes of work. The effects are particularly noticeable on polymorphic / many to many polymorphic relationships.

He then includes the code required to create the indexes on your tables (either a single column or a compound index involving more than one column) in your migrations. He also provides code examples showing how to use foreign keys to improve one-to-one/one-to-many relationships. More examples include optimizations for many-to-many relationships and polymorphic relationships.

tagged: tutorial laravel index foreignkey relationship model migration optimize

Link: https://sampo.co.uk/blog/speed-up-relationship-queries-in-laravel

Delicious Brains Blog:
WP-CLI Packages: Supercharge Your WordPress Development
Jan 24, 2018 @ 17:55:59

The Delicious Brains site has a tutorial posted showing you how to supercharge your WordPress development with the help of WP-CLI packages.

I think most developers would agree that my-hacks.php. It is my favorite way to set up new WordPress sites, control WordPress with CRON, manage plugins, quickly test code, and a whole host of other tasks that are quicker and easier to complete via the CLI or a shell script.

“What,” you might ask, “could possibly be better than WP-CLI?”. “A lot of things…” I would reply [...] but then I might catch myself and realize that your question was probably scoped to WordPress development and related tools so I would cough loudly and continue, “cough I mean… Packages… For WP-CLI. WP-CLI Packages”

The post then goes on to talk about the WP-CLI package index and some of the packages they like to use including:

  • aaemnnosttv/wp-cli-login-command
  • binarygary/db-checkpoint
  • markri/wp-sec

Each includes a brief summary of what the package offers and a code example of it in use. The post ends with some unfortunate news, however - that the package index is essentially dead.

tagged: wpcli packages index tutorial introduction list

Link: https://deliciousbrains.com/wordpress-cli-packages-review/

SitePoint PHP Blog:
How to Optimize MySQL: Indexes, Slow Queries, Configuration
Oct 31, 2017 @ 15:46:11

On the SitePoint PHP blog Bruno Skvorc has a post that offers some helpful advice about optimizing your MySQL database through the use of indexes, monitoring slow queries and configuration options.

MySQL is still the world’s most popular relational database, and yet, it’s still the most unoptimized – many people leave it at default values, not bothering to investigate further. In this article, we’ll look at some MySQL optimization tips we’ve covered previously, and combine them with novelties that came out since.

He starts off with the configuration changes that can be used to optimize the database, tweaking settings for Innodb pool, handling variable inspection and using a tuning tool to determine the best settings. Next up comes the look at indexes covering the different kinds first: fulltext, descending, unique/primary and regular indexes. Finally he covers some of the usual bottlenecks seen in MySQL's use in web applications, showing how to monitor for them via the slow query log.

tagged: optimize mysql database application tutorial index slowquery query configuration

Link: https://www.sitepoint.com/optimize-mysql-indexes-slow-queries-configuration/

Kevin Schroeder:
If you develop for Magento, know your indexes
Feb 02, 2015 @ 15:34:19

Kevin Schroeder makes a suggestion to all of the Magento developers out there - be sure to know your indexes and how to use them to your advantage.

When I first got into Magento development, in my mind, there were two ways of getting data from the database. You would either call Mage::getModel(‘catalog/product’)->load($id) or you would work with the collection. If you wanted to get a filtered list of something you would use the ORM to get it. But as I’ve gained more experience (fairly quickly, I might add) I realized that there was more to the puzzle. A good portion of this is because I work with Magento ECG and some of the best Magento devs and architects can be found there and I’m a quick learner.

He gives an example of going beyond the usual one-to-one relationship most people use with Magento's models. He includes an example of wanting to fetch a list of all products in the same category as another and the "anit-pattern" that comes with it. Instead he offers the solution of an index, a simple one that merges the catalog category and product index ID. This makes using a custom query with a handy join much easier and much faster.

tagged: magento database collection query index tutorial category

Link: http://www.eschrade.com/page/if-you-develop-for-magento-know-your-indexes/

Reddit.com:
Composer files being indexed by Google
Dec 10, 2014 @ 17:36:55

In an interesting thread on the /r/php subreddit on Reddit.com, a user noticed that Google is indexing Composer files that are in the document root of PHP applications. These files, like "composer.json" and "composer.lock" can provide detailed information about which packages and libraries are in use in the application (information disclosure).

The problem is that these files are placed in the web root of the application and not in a folder one level up, a recommended practice. The post links to a Google search that shows an example of current sites with the issue.

Another comment in the same post also reminds users not to have things like their ".git" files in the document root either as they can provide valuable information to would be attackers about your application's code. Things can be done to prevent direct access to these files in the web server configuration but it's far better to restructure the application to have them in a parent directory of the actual web root.

tagged: composer files composerlock composerjson index google search engine security

Link: http://www.reddit.com/r/PHP/comments/2ourf7/composer_files_being_indexed_by_google/

DZone.com:
MongoDB Driver Tips & Tricks: PHP
Jun 04, 2014 @ 15:10:49

On DZone.com there's a new post from Chris Chang that's the third part of the series looking at using various language drivers for working with MongoDB. In this latest article he focuses in on the PHP driver, giving a brief introduction and a few handy tips.

This blog post is the third of a series where we are covering each of the major MongoDB drivers in depth. The driver we’ll be covering here is the PHP driver, developed and maintained by the MongoDB, Inc. team (primarily @derickr, @bjori and @jmikola).

He includes a link to some basic examples and shares a "production-ready connect string" with some MongoLab recommended settings. The tips include topics ranging from working with index builds, the lowering of is_master_interval and configuring the connectionTimeoutMS setting for optimum connection handling.

tagged: mongodb driver tips tricks mongolab index master interval connection timeout

Link: http://java.dzone.com/articles/mongodb-driver-tips-tricks-php

Stephan Hochdörfer:
Speeding up your Satis run
May 02, 2014 @ 14:11:40

Stephan Hochdörfer has a new post with a handy tip on speeding up the indexing Satis does on your local repositories to generate its information. His tip involves being more selective in the rebuild process, only indexing the projects that might need it.

In the last couple of months this [indexing] process takes quite a while because Satis rebuilds the index for every repo it knows about. Since we deal with quite a few repos containing a large amount of versions it slowed down the "build time". Obviously it does not make any sense to run Satis on a repo that has not changed. Since Satis was lacking this feature I started hacking on it and I am happy that the feature got merged into master this morning.

With his patch, you can specify only the repository you want reindexed via the "build" command. You can even specify multiple repositories to rebuild, allowing for a bit more automation around the process.

tagged: satis repository index speed performance patch single

Link: http://blog.bitexpert.de/blog/speeding-up-your-satis-run/

PHPClasses.org:
7 Reasons Why WordPress Made PHP Popular, not PHP Frameworks
Jul 31, 2013 @ 15:11:23

On PHPClasses.org today there's a new post from Manuel Lemos suggesting that one of the main reasons why PHP is popular is because of WordPress, not the frameworks that have been built with it.

Recently the Tiobe Index of published an update of their programming language index on which they claim PHP has been raising in popularity due to Zend Framework 2 but they do not justify why. Read this article to learn about an opinion why this claim is unfounded and PHP popularity has more to do with WordPress than with PHP at one language may be more popular than PHP Frameworks.

In the post he talks some about the TIOBE index, how it ranks popularity and where PHP currently sits on the list. He then lists out seven reasons why he thinks that WordPress made PHP as popular as it is including:

  • WordPress is the Most Popular PHP Application
  • WordPress alone is much more popular than any PHP framework
  • The Extensible WordPress plugin ecosystem
  • Non-Programmers develop in PHP just because of WordPress

He also suggests that the popularity of WordPress stems from it solving a more pragmatic problem than PHP frameworks

tagged: wordpress framework popularity opinion tiobe index

Link: http://www.phpclasses.org/blog/post/215-7-Reasons-Why-WordPress-Made-PHP-Popular-not-PHP-Frameworks.html

Pixelstech.net:
TIOBE: PHP is coming back
Jul 10, 2013 @ 17:22:02

According to this new post on the Pixelstech site, PHP is "making a comeback" with an increase in popularity since it was last measured on the TIOBE index.

TIOBE released the programming language index for July 2013. The highlight of this month is that PHP is coming back. It ranks the fifth and has an increase of 1.54% compared to January. There are no changes in the ranking for the top 4 languages. The reason why PHP is back may be attributed to the new PHP Zend Framework that was released in September 2012, but this reason is not very convincing.

The post includes the list of the top twenty languages ordered by popularity with C, Java, Objective-C and C++ coming in at the four spots above PHP now.

tagged: tiobe index popularity programming language

Link: http://www.pixelstech.net/article/1373365267_TIOBE%3A_PHP_is_coming_back

PHPMaster.com:
MongoDB Indexing, Part 2
May 13, 2013 @ 15:36:46

PHPMaster.com has posted part two of their series looking at indexing in MongoDB databases (part one here) with some more advanced concepts Mongo makes available.

In part 1 of this series we had an introduction to indexing in MongoDB. we saw how to create, use, and analyze queries with indexes giving us a good foundation to build on. In this part, we’ll take a look at a few more small but important concepts, like indexing on sub-documents and embedded fields, covered queries, and index direction.

They use the same "posts" collection from the previous article, showing you how to index it based on a "location" sub document and "embedded fields" inside of it. They also touch on complex sorting with a multi-field index and the idea of "covered queries." These are queries that all fields queried are part of an index as well as all returned. They finish up the article by showing you how to remove indexes too.

tagged: mongodb index tutorial example series query

Link: http://phpmaster.com/mongodb-indexing-2


Trending Topics: