Skip to content

Mastering PHP and Laravel

Never stop learning!

Menu

  • Home
  • Blog Posts

Blog Posts

How to quickly toggle xdebug

When running unit tests, xdebug will slow things down quite a bit. Most of the time we run tests we don’t need xdebug because we are not doing code coverage, or actually debugging. Here is how I quickly toggle xdebug

Kenny January 12, 2023January 21, 2023 Blog Posts, Mac Terminal / Linux, Programming No Comments Read more

Software Engineering Books

My Book List For 2022 As an Amazon Associate, I earn from qualifying purchases. This page contains affiliate links. If you choose to purchase after clicking a link, I may receive a commission at no extra cost to you. These

Kenny November 23, 2022January 21, 2023 Blog Posts, Uncategorized No Comments Read more

PHPStorm Shortcuts For Mac

Here are some great keyboard shortcuts I have set up to help you become more efficient in PHPStorm!

Kenny July 15, 2022January 21, 2023 Blog Posts, Uncategorized No Comments Read more

Inject Storage in Laravel

How do you inject Storage in Laravel? I’ve noticed in my Google searches that all the examples I come across on how to use the various components of Laravel only show how to use Facades. But what if you want

Kenny May 20, 2021January 21, 2023 Blog Posts, Uncategorized No Comments Read more

PHP 8 Named Arguments

In PHP 8, you can use named arguments, which allows you to provide the parameters of a function in any order: PHP 7.x PHP 8 Even if you choose not to reorder the params, it will make the code clearer

Kenny January 30, 2021January 21, 2023 Blog Posts, Uncategorized No Comments Read more

A fast way to reformat code in PHPStorm

Today I found a way to do a regex find that makes reformatting code easy. Let’s say we have some code like this: and you want it formatted like this: This is what I prefer because it gives more breathing

Kenny August 25, 2020January 21, 2023 Blog Posts, Uncategorized No Comments Read more

pushd / popd

I learned a great Linux command today! I find myself jumping between my web directory and the apache config directory occasionally on my server, and by using pushd from the web directory, I’ll now be able to quickly return to

Kenny June 10, 2020January 21, 2023 Blog Posts, Uncategorized No Comments Read more

Learning Docker

Today I finished the tutorial for Docker, located at https://www.docker.com/101-tutorial This is something I’ve been wanting to dive into for a whale (I mean while) 😉

Kenny June 9, 2020January 21, 2023 Blog Posts, Uncategorized No Comments Read more

Pipelines

Have you heard of the pipeline pattern? The pipeline pattern is used by Laravel internally, and is a really nice way to clean up your code. I found a video that explains it well. I watched yesterday, then today I

Kenny June 5, 2020January 21, 2023 Blog Posts, Uncategorized No Comments Read more

Keeping busy during trying times

Having so much time off as I have lately, I’ve been taking the opportunity to clean up my online digital world a bit. Things like creating headers for all the social accounts tied to our Basenji Adventures brand, and creating

Kenny May 7, 2020January 21, 2023 Blog Posts, Uncategorized No Comments Read more

The current state of things

It’s amazing how life gets going in a rhythm, and you get your head down and working so hard, that you sometimes forget to look around (or in this case, write in your blog). Working at a small travel advertising

Kenny March 26, 2020January 21, 2023 Blog Posts, Javascript, Laravel, Learning, PHP, Programming No Comments Read more

Sorting Associative Arrays in PHP

$arr = [ ‘foo’ => ‘bar’, ‘faz’ => ‘baz’ ]; array_multisort(array_column($arr, ‘value’), SORT_ASC, $arr); You can sort an associative array with one line of code as I did above. As a result, the array becomes sorted by the keys: [

Kenny January 6, 2020January 21, 2023 Blog Posts, Learning, PHP, Programming No Comments Read more

PHPStorm – Stop those accidental tab closures!

If you’re like me, you have probably had this happen. You go to click on one of the many tabs you have open in PHPStorm, only to accidentally click the X, and close it. ARGH! Today I found a way

Kenny October 9, 2019January 21, 2023 Blog Posts, PHP, PHP Storm, Programming, Tools No Comments Read more

Defensive Programming | Laravel find()

Defensive Programming One of the things I’ve learned in my career is to code defensively. Laravel makes it very easy to ask for an object, but it also makes it very easy to get it wrong. If you request an

Kenny February 5, 2019January 21, 2023 Blog Posts, Eloquent, Laravel, PHP No Comments Read more

WordPress permalinks not working

WordPress permalinks not working? I feel your pain. Read on… Recently, after setting up another virtual host on my Linux server, for a WordPress site, permalinks were not working. Any page other than home was getting a 404 error. I

Kenny January 20, 2019January 21, 2023 Blog Posts, Learning, Linux No Comments Read more

Some resources

Here are some great resources I found recently. Unsplash Free Stock Photos Remove.bg Remove background from portraits Page Cache Whole page caching IsoRepublic.com Free hi-res photos and videos

Kenny December 20, 2018January 21, 2023 Blog Posts, Programming No Comments Read more

Laravel – the difference between all() and get()

When dealing with a model, all()  is a static method. It creates a new query object, and runs get()  on that object get()  is not static, but can be called statically because of a magic method in the Model class.

Kenny October 12, 2018January 21, 2023 Blog Posts, Eloquent, Laravel, Learning, Programming No Comments Read more

Laravel Eloquent only()

$fullModel = Model::find(1) // Get model with id 1 $idArray = $fullModel->only(‘id’) // array containing id // this does not work. You’ll get back an empty collection // It is trying to pull the id column off the collection object,

Kenny October 12, 2018January 21, 2023 Blog Posts, Eloquent, Laravel, Learning, Programming No Comments Read more

MySQL Stored Procedures

Here is a tip you can use when writing a stored procedure, and using prepared statements. Since you have to pass the statements in through EXECUTE stmt USING …   it can get confusing if there are a large number of

Kenny October 11, 2018January 21, 2023 Blog Posts, Learning, MySQL, Programming No Comments Read more

Laravel Eloquent Attributes

When dealing with an Eloquent model, you can add your own attributes. These can be useful for computed values. For example: class Person extends Model { // By default, all the database fields will be available. // Let’s assume for

Kenny October 9, 2018January 21, 2023 Blog Posts, Laravel, Learning, PHP, Programming No Comments Read more
  • « Previous

Archives

Categories

  • Blog Posts (90)
  • iPhone (2)
  • Learning (42)
  • Linux (4)
    • Debian (1)
  • Mac Terminal / Linux (6)
  • Other Stuff (1)
  • Programming (68)
    • .NET (1)
      • C# (1)
    • Java (1)
    • Javascript (6)
      • AngularJS (1)
      • Node.js (2)
    • MySQL (3)
    • Objective C (1)
    • PHP (45)
      • Community (5)
      • Laravel (9)
        • Eloquent (3)
    • SQL (7)
    • Tools (2)
      • PHP Storm (1)
  • Slim Framework (1)
  • Uncategorized (9)
  • WordPress (3)
Copyright © 2023 Mastering PHP and Laravel. All rights reserved. Theme Spacious by ThemeGrill. Powered by: WordPress.