Posts

Creating Reusable Bootstrap Elements With Laravel's Make:Component

Bootstrap is a good system for getting an application’s layout started and it comes with lots of helpful user interface elements that we can use in our application. The downside, is there tends to be a lot of duplication in our source code to support these elements. Thankfully, Laravel added components in the 7.x branch which will allow us to reduce that duplication.

Read More

Working With Soft Deletes in Laravel (By Example)

Laravel provides a built-in feature that allows us to flag database rows as deleted without actually deleting them from the database. This article discusses how we can get started using them.

Read More

Link Post and Podcast Roundup: May 2020 Edition

Link Post Logo

May’s links.

Read More

Select Distinct With Conditions in MySQL

The other day I ran into an interesting problem with an SQL query, I needed to create the count() of all items and the count() of a specific set of items. Normally, I would use subqueries but there was so much data that the subqueries took a minute and that was not acceptable to our client (I wrote the query originally with a small amount of data and after 4 years the performance of it was horrible).

Read on to see how to fix this.

Read More

Exporting Specific Tables in MySQL Using mysqldump

The other day we needed to restore a single table from a database for our testing environment. Thankfully, MySQL provides an easy solution to this problem.

Read More

Link Post and Podcast Roundup: April 2020 Edition

Link Post Logo

April’s links.

Read More

5 Quick Ways to Make Your Code More Maintainable

In Clean Code, Robert Martin gives us the following helpful piece of information.

.. [T]he ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. …[Therefore,] making it easy to read makes it easier to write.

With this in mind, we would like to give you 5 tips on how you can improve your code so it’s more readable.

Read More

Fixing the 'Target class [config] does not exist' Error

The other day I pushed a new test to our Jenkins server and I received the following error.

1) Tests\Unit\NewTest::testIfDeletedBeforeStartDateThenWrongHire
Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist.
 
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:805
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:681
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:629
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:769
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:1245
/var/www/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:270
/var/www/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:101
/var/www/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:77
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1253
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1219
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1051
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:968
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1004
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:957
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1618
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1630
/var/www/tests/TestCase.php:152
/var/www/tests/TestCase.php:116
/var/www/tests/TestCase.php:70
/var/www/tests/Unit/NewTest.php:17
/home/jenkins/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:200
/home/jenkins/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:159
 
Caused by
ReflectionException: Class config does not exist
 
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:803
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:681
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:629
/var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:769
/var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:1245
/var/www/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:270
/var/www/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:101
/var/www/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:77
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1253
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1219
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1051
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:968
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1004
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:957
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1618
/var/www/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1630
/var/www/tests/TestCase.php:152
/var/www/tests/TestCase.php:116
/var/www/tests/TestCase.php:70
/var/www/tests/Unit/NewTest.php:17
/home/jenkins/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:200
/home/jenkins/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:159

The issue was that I had forgotten to include parent::setup() in the test class’ setup() function.

What the F*ck Is With All the Artisan Commands: Queues

Work queues allow you to perform tasks that are slow or error-prone outside of the current user’s request to improve their experience with your site. Read on to learn how you can use work queues in Laravel for your projects.

Read More

Link Post and Podcast Roundup: March 2020 Edition

March’s links.

Read More

Join Our Mailing List!

View previous campaigns.

subscribe via RSS

All content copyright This Programming Thing 2012 - 2020
Blogging about PHP, MySQL, Zend Framework, MySQL, Server Administration and Programming in general