Newton Job (@_newtonjob) 's Twitter Profile
Newton Job

@_newtonjob

Helping Laravel developers write cleaner, smarter code.

🥷 Master of #Laravel.
💅 TALL | VILT | LEMP
🔢 Mathematician
🎹 Keyboardist

ID: 1570716385008926720

linkhttps://github.com/newtonjob calendar_today16-09-2022 10:10:21

6,6K Tweet

3,3K Takipçi

165 Takip Edilen

Newton Job (@_newtonjob) 's Twitter Profile Photo

Did you know about Laravel's Timebox utility? You can timebox a closure to run for a fixed amount of time, even if an exception was thrown. Very useful for preventing timing attacks, where returning too early for certain scenarios could leak logical information.

Did you know about Laravel's Timebox utility?

You can timebox a closure to run for a fixed amount of time, even if an exception was thrown.

Very useful for preventing timing attacks, where returning too early for certain scenarios could leak logical information.
Newton Job (@_newtonjob) 's Twitter Profile Photo

When writing commands, if you're going to write some info text to the terminal, what do you do? $this->info(...) right? But you can get a much better output if you instead use: $this->components->info(...) There's also error(), warn(), and a bunch of other nice methods as well.

When writing commands, if you're going to write some info text to the terminal, what do you do?
$this->info(...) right?

But you can get a much better output if you instead use:
$this->components->info(...)

There's also error(), warn(), and a bunch of other nice methods as well.
Newton Job (@_newtonjob) 's Twitter Profile Photo

If you're sending temporary download files to users, like exports, one nice tip is to put them in a dedicated directory like "temp", where you can conveniently clean them up periodically.

If you're sending temporary download files to users, like exports, one nice tip is to put them in a dedicated directory like "temp", where you can conveniently clean them up periodically.
Newton Job (@_newtonjob) 's Twitter Profile Photo

Rare gem that more people need to know about. 💯 I even now drop the password_rest_tokens table and just use the cache driver. Laravel supports it out of the box.🤘

Newton Job (@_newtonjob) 's Twitter Profile Photo

Remember that you can easily spin through potentially thousands of models in a very memory-efficient way by just chaining on `->each()` directly on the Eloquent builder. 🍃 Just make sure you *don't* `->get()` the results.

Remember that you can easily spin through potentially thousands of models in a very memory-efficient way by just chaining on `->each()` directly on the Eloquent builder. 🍃

Just make sure you *don't* `->get()` the results.
Newton Job (@_newtonjob) 's Twitter Profile Photo

Using ->withDefault() on your relationship definition can be very useful for relationships that you know MUST exist. This can help avoid unnecessary conditional checks everywhere.

Using ->withDefault() on your relationship definition can be very useful for relationships that you know MUST exist. This can help avoid unnecessary conditional checks everywhere.
Newton Job (@_newtonjob) 's Twitter Profile Photo

As someone using Forge every day, no one needs to tell me that a *lot* of attention was put into this thing. The experience just feels so smooth. Prefetching is also quite heavily used. I'm definitely picking ideas to use in my projects. 💅

As someone using Forge every day, no one needs to tell me that a *lot* of attention was put into this thing. The experience just feels so smooth. 

Prefetching is also quite heavily used. I'm definitely picking ideas to use in my projects. 💅
Newton Job (@_newtonjob) 's Twitter Profile Photo

We often dispatch closures to run in the queue, but we don't often talk about how Laravel managed to pull this off! Especially with PHP closures not being natively serializable. The magic happens in the laravel/serializable-closure package, and it unlocks a lot of possibilities.

We often dispatch closures to run in the queue, but we don't often talk about how Laravel managed to pull this off! Especially with PHP closures not being natively serializable.

The magic happens in the laravel/serializable-closure package, and it unlocks a lot of possibilities.
Newton Job (@_newtonjob) 's Twitter Profile Photo

Needed to refresh the active tenant in a singleton service across queued jobs, and realized it was just way too convenient. 🤫

Needed to refresh the active tenant in a singleton service across queued jobs, and realized it was just way too convenient. 🤫