laravel

All my posts about laravel.

Dockerize your Laravel app with Vessel

Chris Fidao has created an easy to handle, well documented, Docker dev environment for Laravel projects. It's an excellent starting point if you want to have a taste of what Docker can do.

For the introductory newsletter:

I like Vessel the best for the following reasons: 1. It's installed per-project instead of globally. This lets me customize it per project if need be. 2. Docker lets me change out versions of software such as Nginx, MySQL, Redis, and others very easily. (I've often needed to use an older MySQL version at work) 3. Docker lets me add extra software (perhaps Beanstalkd for queues, or PgSQL for database) really easily 4. Docker containers are more like processes than VMs. They generally only use what resources they need (with some caveats, but even with those, they're lighter than Vagrant virtual machines) 5. I can fill up my workstation with one technology (Docker!) instead of many (PHP, Redis, MySQL, etc) with all their configuration files and data strewn about all over my file system 6. You can expand on your dev workflow to build up to a production workflow using all the same technology (Docker!) - You can check out Shipping Docker for my full course on bringing Docker from dev into production.

https://vessel.shippingdocker.com

Read more

Join 9,500+ smart developers

Get my monthly newsletter with what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.

No spam. Unsubscribe anytime. You can also follow me on X.

Handling Stripe webhooks in a Laravel application original

by Freek Van der Herten – 5 minute read

In the project I'm currently working on I had to integrate Stripe webhooks. Stripe has great documentation on how to handle webhooks, but it still took a fair amount of time to get the integration just right. My solution for handling webhooks is pretty generic and reusable by others. I decided to…

Read more

Essential image optimization

Addy Osmani, a Google Chrome engineer, recently published a e-book on image optimization. You can read it in it's entirety here: https://images.guide/

Images take up massive amounts of internet bandwidth because they often have large file sizes. According to the HTTP Archive, 60% of the data transferred to fetch a web page is images composed of JPEGs, PNGs and GIFs. As of July 2017, images accounted for 1.7MB of the content loaded for the 3.0MB average site.

Per Tammy Everts, adding images to a page or making existing images larger have been proven to increase conversion rates. It's unlikely that images will go away and so investing in an efficient compression strategy to minimize bloat becomes important.

If you need to optimize images in your PHP application take a look at our image optimization package. If you're a Laravel user you'll be happy to know that there's also a Laravel version of the optimizer. Our Laravel Medialibrary also comes with built-in support for optimizing images.

Read more

Handling Stripe payments in Laravel

Povilas Korop, creator of Laravel Daily and Quick Admin Panel, wrote an extensive guide on how to integrate Stripe into a Laravel application.

Stripe is one of the most popular payment merchants for web, but information about Laravel integration is pretty fragmented, so I decided to write a really long tutorial about this topic.

We will cover:

  • General logic how Stripe works
  • Simple one-time payment integration
  • Testing and production environment setup
  • Saving transaction data for future reference
  • Recurring payments with Laravel Cashier
  • Getting invoices data and PDF download

https://quickadminpanel.com/blog/stripe-payments-in-laravel-the-ultimate-guide/

Read more

New features in our packages original

by Freek Van der Herten – 3 minute read

Every time our team releases a package I have the habit of writing an introductory blogpost. But after the initial release most pages gain more features through PRs by the community and ourselves. Mostly these new feature go unnoticed. That's why I plan on regularly writings posts on noteworthy…

Read more

Building an SMS admin powered by Laravel and Nexmo

JMac, the creator of Laravel Shift, shared how he can very easily spin up a new job on his service by sending a simple SMS message.

In the end, all I need is a quick way to run a Shift on the go. Looking back on almost two years of support, I often have the Shift number readily available. Creating the job and adding it to the queue is at most two lines of code. So the steps are not the pain point.

The pain point is connecting to the server. Unless I want to carry my laptop around, I can’t connect to the server to run the Shift. (I actually have taken my laptop with me during peak times.)

What do I carry around with me all the time? My phone. I’m already reviewing the support emails from my phone. Wouldn’t it be great when I need to run a Shift manually to just reply or send a text.

https://jason.pureconcepts.net/2017/09/nexmo-sms-admin-laravel/

Read more

Goodbye controllers, hello request handlers

Jens Segers, developer at Teamleader and author of the popular Optimus and laravel-mongodb packages, wrote about an alternative to controllers.

Let me introduce you to request handlers. The concept is very simple, yet very unknown to a lot of PHP developers. A request handler is basically a controller, but limited to one single action. This concept is very similar to the Action-Domain-Responder pattern which was proposed by Paul M. Jones, an alternative for the MVC pattern that focuses on a more clear request to response flow for web applications.

https://jenssegers.com/85/goodbye-controllers-hello-request-handlers

Read more

Prepare your website for iPhone X

Last week Apple introduced their new fancy iPhone X. It's screen has a top notch that might cause some problems in landscape mode. Stephen Radford explains how to properly handle it.

The new iPhone X features a beautiful edge-to-edge display. Well, almost. There is the small issue of a notch at the top of the browser which doesn't cause an issue when viewing websites in portrait but by default does cause some issues in landscape.

To accommodate the notch iOS 11 constrains websites within a "safe area" on the screen. On most websites this results in letterboxing on the left and the right.

http://stephenradford.me/removing-the-white-bars-in-safari-on-iphone-x/

We've already implemented the fix in our Laravel application template.

Read more

Who uses PHP (and Laravel) anyway?

Colin DeCarlo, a developer at Vehikl, wrote some thoughts on why PHP has a bad reputation in some circles.

People shitting on PHP isn’t going to go away, it’s a symptom of a few things. PHP has a ridiculously flat learning curve so just about anyone can write code using it, this means a lot of amateurs and ‘get it done’ developers will choose php but won’t really ever level up their skills when it comes to software development.

https://medium.com/@colindecarlo/who-uses-php-anyway-672115ab81de

I agree with Colin on everything he writes in his post. I'm also thinking that the some of the reasons on why people don't like PHP apply to Laravel as well. In my mind Laravel is to PHP frameworks what PHP is to other programming languages. Both Laravel and PHP might not do everything by the "real programming rules", but it sure is easy to use. And when handled properly powerful and maintainable stuff can be built with it.

Because Laravel is an easy framework to get started with, it's a popular choice for newcomers. Even with almost no experience you can build an app. Some of those projects will go to production. If an experienced developer that uses another framework comes by and sees that Laravel app, it might be easy to conclude that the problem lies with Laravel, and not with the inexperience of the junior programmer who just begon his/her journey in coding.

Read more

Extending models in Eloquent

Caleb Porzio, co-presenter of the Twenty Percent Time podcast, published a new article on the Tightenco blog. This time he guides us through a nice use case for extending Eloquent models.

Let’s explore another alternative that can be used as a stand-in for repetitive where statements and local scopes. This technique involves creating new Eloquent models that extend other models. By extending another model, you inherit the full functionality of the parent model, while retaining the ability to add custom methods, scopes, event listeners, etc. This is commonly referred to as “Single Table Inheritance,” but I prefer to just call it “Model Inheritance”.

https://tighten.co/blog/extending-models-in-eloquent

Read more

Build a Facebook Messenger chatbot in Laravel

In a new article on his blog, Christoph Rumpel shows how you can easily set up a Facebook Messenger chatbot using the shiny new v2 of Botman Studio. Very cool stuff.

Although it seems quite easy to setup BotMan Studio and Facebook you still need to be aware of a few concepts regarding Facebook. I hope I could provide them there and this article helps you to setup your next Facebook Messenger chatbots. From here you are ready to build more and more features to your bot your own. So make sure to checkout the BotMan documentation to get a feeling of what is possible and learn new stuff.

http://christoph-rumpel.com/2017/09/build-a-facebook-chatbot-with-laravel-and-botman-studio/

Read more

The dangers of mutable datetime objects

Jeff Madsen wrote down a good piece that explains how mutable Carbon dates can lead to some nasty bugs. I would't mind if Chronos were to be promoted to the default datetime library in Laravel.

If you hang out on any sort of programming forums you have no doubt encountered “The Great Mutable vs. Immutable Debate”. While I’m sure you know what the words mean, if you are new to programming or don’t have a strong Computer Science background it might not be obvious to you whether this is an important concept to be concerned with, or just more “architecture astronaut” purists arguing some obscure fine point.

To help you answer that for yourselves, I’m going to show you the difference between the two using two popular Php DateTime libraries — Carbon and Chronos, and then demonstrate the danger of using the mutable one of those.

https://medium.com/@codebyjeff/whats-all-this-immutable-date-stuff-anyway-72d4130af8ce

If you want to read more cool articles by Jeff, be sure to subscribe to his excellent newsletter.

Read more

A recap of Laracon EU 2017

Devron Baldwin wrote down a few words on the excellent Laracon EU conference, edition 2017.

The awesome talks and the amazing people made Laracon EU 2017 an experience to remember. I’ll split this up into a few sections to talk about the non-technical and the technical talks. I found myself enjoying the non-technical talks slightly more than the technical this year.

https://medium.com/@devron/7-laracon-eu-2017-talks-and-the-people-i-met-381e55ebf898

I can't believe it' already over and am already looking forward to Laracon EU 2018.

Read more