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

Tomas Votruba:
When You Should Use Monorepo and When Local Packages
Nov 20, 2018 @ 09:19:48

In a new post to his site Tomas Votruba shares his opinions on project structure and when he sees it appropriate to use a "monorepo" and when to use packages to compose your application.

Recently I gave a few talks about monorepo in PHP and how to integrate it to companies in a useful way. I'm very happy to see many people already use it and know what problems it solves.

Before monorepo hype takes over private PHP projects, I think you should know about its limits: When is the best time for you to go monorepo? When you gain less complexity while integrating it? How can you make the transition better? Is it really needed?

He starts off by describing some of the most common application structures including the monorepo, many-repository, and local package approaches. He sees each as an evolution on the previous and shares when he thinks the evolution makes the most sense (hint: it's about value). He ends the post by sharing a few final thoughts about monorepos and when they make sense for private projects versus public, open source projects.

tagged: monorepo package application project structure opinion

Link: https://www.tomasvotruba.cz/blog/2018/11/19/when-you-should-use-monorepo-and-when-local-packages/

CodeWall:
Install Summernote With Laravel Tutorial
Oct 30, 2018 @ 10:33:21

On the CodeWall site they've posted a new tutorial showing you how to integrate the Summernote WYSIWYG editor into your Laravel application for easier content creation. Summernote is one of many potential WYSIWYG editors that will work easily with Laravel.

What You See Is What You Get (WYSIWYG), is mostly used by the developers for describing a software program which they use for checking visibility of the final product. A user friendly interface is required to run WYSIWYG program. While to write descriptive codes, a developer could use WYSIWYG editor which helps them to see the content that will appear as the end result.

[...] Well users of Laravel have good news, it supports multiple WYSIWYG editors. Therefore, if you are a developer and like developing applications with this brilliant framework, you’re in luck. In this article, I will elaborate about the best WYSIWYG editors you can use working with Laravel. With a plethora of WYSIWYG editors available, it’s quite hard to decide which one best suits your needs. Well, you don’t have to worry a bit. I will provide a detailed account on some of the best Laravel WYSIWYG editors in this article. With these editors, you can easily develop your content and codes. I will also highlight the pros and cons of WYSIWYG editors.

They made the choice to go with Summernote and walk you through the integration process including:

  • a listing of some of the prerequisites
  • configuring the database and making migrations for the content
  • building out the routes, models, views, and controllers

They also show how to add the Summernote instance to a view and configure it to your liking.

tagged: summernote tutorial laravel application integration

Link: https://www.codewall.co.uk/install-summernote-with-laravel-tutorial/

Twilio Blog:
How to Send SMS Reminders from PHP Symfony Applications
Sep 25, 2018 @ 09:42:18

On the Twilio blog today Sylvan Ash has written up a tutorial showing how to send SMS reminders from a Symfony application as reminders of certain events.

If you have a booking system, making appointments such as massage or other therapist bookings, dental or medical appointments, etc., you’d probably like to remind the client about the booking they made on the day of the appointment. In some cases, you might also want to remind the person offering the service. In this tutorial, you'll learn how to send SMS reminders to clients of their upcoming massage appointments, at a designated time before the appointment, in a Symfony project using Twilio's SMS service.

The tutorial starts with a brief description of the setup and uses Composer to create a new Symfony project (the "Appointments" application). It then moves on to the models, defining the structure for the User and Appointment entities. It also shows how to make use of the seeding functionality to create several default users. Next up comes the Twilio integration: installing the SDK via Composer, defining the configuration and adding the client as a service.

With all of that set up, the final pieces are shown: the command to send the SMS messages via the Twilio service and the cron job to run it once a day at midnight.

tagged: symfony tutorial send sms application reminder appointment

Link: https://www.twilio.com/blog/sending-sms-reminders-with-symfony-php-framework

TheCodingMachine.io:
Building a Single-Page Application with Symfony 4, Vue.js, Vue Router, Vuex and
Sep 11, 2018 @ 10:20:32

On The Coding Machine site author Julien Neuhart has written up a tutorial showing how to create a single-page application using Symfony 4 along with Vue.js, the Vue router, Vuex and Axios.

With Symfony, I used to build my web applications in a traditional way: the framework handles everything, from the routing to the page rendering. However nowadays web applications have complex user interactions and the previous approach does not fit well for such cases. That's where single-page application architecture comes to the rescue.

The tutorial walks you through the creation of an application where users can post messages wrapped up in a nicer Docker-ized environment. He starts with the creation of the development environment and project structure including the Docker setup and installation of the needed dependencies. From there he starts in on the frontend, creating the Vue.js code for the application and moving to the backend for the initial Symfony index route. He shows the creation of the Vue routing, handing the requests in Symfony, the creation of the Post entities and API functionality.

The post also includes the addition of User entities with usernames/passwords for authentication and the Symfony routes to handle those requests. The tutorial ends with some improvements to the initial setup including user role addition, CSRF tokens, error messaging and other Docker customizations.

tagged: tutorial symfony4 vuejs vuex vuerouter axios singlepage application

Link: https://thecodingmachine.io/building-a-single-page-application-with-symfony-4-and-vuejs

Tomas Votruba:
4 Ways to Add Global Option or Argument to Symfony Console Application
Sep 04, 2018 @ 09:49:49

Tomas Votruba has a new post to his site showing you how to add a global option or argument to your application that makes use of the Symfony Console component. In this case, a "global" option is one that can be given to any command in the application. For his needs, it's a filename.

I'm working on 3 Console Commands. All was good, until I needed to add an argument to all commands at once... and in lazy, extensible, maintainable way.

He starts by talking about some of the "why" behind the need to run multiple commands at once. He shows an example of having multiple CHANGELOG files and the need to define the output file for each rather than just one file. He then goes through four different possible implementations, including the code and pros/cons of the approach:

  • Add Argument to Each Command
  • Modify Application Definition
  • The Symfony Event Subscriber Way
  • Extend the Application

He ends the post mentioning the one he prefers (the last one on the list) and briefly mentions anti-patterns and finding the right solution over just the first one you find.

tagged: symfony console application option global changelog tutorial

Link: https://www.tomasvotruba.cz/blog/2018/09/03/4-ways-to-add-global-option-or-argument-to-symfony-console-application/

Titouan Galopin:
How to build a scalable Symfony application on Kubernetes
Aug 20, 2018 @ 11:23:17

Titouan Galopin has written up a post to his Medium.com site showing a method he's created to set up a scalable Symfony application on Kubernetes, a container management system.

Modern web applications are complex. The expectations of your users regarding your application are constantly increasing: nowadays, an application needs to be fast, convenient, easy to use and beautiful.

Meeting these demands can become another difficulty in the path towards creating a great product. [...] To ease this new difficulty and decrease the time spent on creating and maintaining these expected features, a modern application usually leverages many different components, from content delivery networks (CDN) to full text search services and load balancers.

[...] When you use such infrastructure, being able to interact easily with all its components from within your application is critical. This is where Kubernetes and Symfony are working together to help you achieve incredible results, extremely quickly.

The post starts by introducing some of the basics around Kubernetes for those not familiar with it and the platform they'll be using: Google Cloud Platform. He then talks some about using Symfony in a Kubernetes environment and the role that scalability plays in how you write your code. He makes a few suggestions to make it easier including:

  • Use Flysystem to store your application files in the managed file store
  • Configure Doctrine to use the provided SQL service
  • Use Redis for your cache and your sessions

There's a description for each item in the list, configuration examples where they'd help illustrate, and some links out to other resources for more information.

tagged: symfony tutorial kubernetes scaleable application docker container

Link: https://medium.com/@galopintitouan/how-to-build-a-scalable-symfony-application-on-kubernetes-30f23bf304e

Laravel News:
Customizing the Laravel View Path
Aug 07, 2018 @ 09:42:41

On the Laravel News site they've posted a quick tutorial showing you how to change the path to views in a Laravel-based application.

In response to our post yesterday about Laravel 5.7 Resources Directory Changes, a reader mentioned that they would prefer to have their application views outside of the resources folder.

I thought I’d write up how you can customize the view path; it’s effortless with Laravel!

The change is made in the views.php configuration file, updating the value for the paths setting. You can point it to a single location (like the application path or resource path) or you can set multiple to tell the framework to search for the view in either. The post ends with a mention one thing to keep in mind about generating views and their location (and moving them around).

tagged: laravel tutorial customize view path resource application

Link: https://laravel-news.com/laravel-view-path

TutsPlus.com:
Get Started With Pusher: Build a Chat App With Channels, PHP, and Vue.js
Aug 02, 2018 @ 14:19:09

On the TutsPlus.com site they've posted a tutorial that, making use of the Pusher service, walks you through the process of creating a multi-channel chat application using it, PHP and Vue.js.

In this post, I'll show you how to write the functional components of a very simple chat app. It's a stripped-down example, but you'll see how Channels can simplify the implementation of real-time communication in a web app.

While the post does include a screencast of the process, it also walks through it in a text format, helping you:

  • set up the server with the Pusher PHP package
  • create the client code on the backend and frontend
  • send messages between the chat windows

The Channels functionality makes it simple to subscribe and see only the messages you want (and not everything that comes down the line). The Pusher PHP library makes the integration simple too.

tagged: tutorial pusher chat application channels vuejs

Link: https://code.tutsplus.com/tutorials/get-started-with-pusher-build-a-chat-app-with-channels-php-and-vuejs--cms-31252

Tomas Votruba:
5 Gotchas of the Bin File in PHP CLI Applications
Aug 02, 2018 @ 12:47:03

Tomas Votruba has a new post to his site sharing five "gotchas" in CLI applications as it relates to the "bin" file.

This post from Master PHP CLI Apps with Symfony cluster will focus on bin files. It's the smallest part of PHP CLI Application, so I usually start with it.

Yet, there are still a few blind paths you can struggle with. I'll drop a few extra tricks to make your bin file clean and easy to maintain.

He starts with a brief definition of what a "bin" file is before getting into his list of "gotchas":

  • recommendations about naming and location of the file
  • setting it up to be autoloaded by Composer
  • including the right "shebang" to have it executed by the correct program
  • changing access rights
  • symlinking in Composer

The post ends with the complete code required to build a simple Symfony CLI application that will autoload libraries correctly and be executable by the system's php binary.

tagged: gotcha top5 list cli commandline application symfony tutorial

Link: https://www.tomasvotruba.cz/blog/2018/08/02/5-gotchas-of-the-bin-file-in-php-cli-applications/

Matt Stauffer:
Enterprise Laravel Help Me: White-Labeled Clothing Stores
Jun 27, 2018 @ 11:04:46

Matt Stauffer has posted the second article in his "Enterprise Laravel" series to his site. In part one he started with a practical approach to seeing how large the codebase is (counting lines). In this new post he takes an example situation (gathered from conversations with other developers) and shows how Laravel can fit its "enterprise" level needs.

Recently, I grew tired of hearing people say, "Laravel is fine for small apps, but when you are working in the Enterprise..." You can almost hear the capital E in enterprise, like they're talking about the starship.

I've spent the last few months trying to gather information about what makes people say this, and also stories of folks who are already successfully working with Laravel in enterprise context. I put out a <a href="https://enterpriselaravel.com/success-stories-survey>survey to collect stories, and wrote and delivered a talk (which I hope to give again soon) titled "Laravel and the Enterprise."

The idea, stemming from a submission via his "help me" form, is an application that lets customers create their own white-label storefronts for clothing. He starts with the submission itself and the issues it points out including:

  • the load caused by adding a new tenant (requires more servers)
  • a messy codebase
  • a more "monolithic" approach as it evolved away from simple CRUD

He then goes through each of the (five) points made and his responses trying to help mitigate the issue. Some of them come with more technical recommendations but for others the answer is more about documentation and processes.

tagged: enterprise laravel whitelabel clothing helpme advice application

Link: https://mattstauffer.com/blog/enterprise-laravel-help-me-white-labeled-clothing-stores/