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

Oh Dear Blog:
Our Gitlab CI pipeline for Laravel applications
Dec 18, 2018 @ 17:14:53

On the "Oh Dear!" blog they've written up a post sharing the Gitlab continuous integration pipeline they use for the deployment of the application. While, in their case, it's a Laravel-based application, the basics of it could be used for just about any PHP application with slight modifications.

We've been fairly public about the amount of testing we have for Oh Dear!. Freek has been showing bits and pieces on his Twitter to show the extent of that effort.

Having a huge test suite is nice, but integrating it into your development workflow is even better.

That's why we're releasing our Gitlab CI pipeline that is optimized for Laravel applications. It contains all the elements you'd expect: building (composer, yarn & webpack), database seeding, PHPUnit & copy/paste (mess) detectors & some basic security auditing of our 3rd party dependencies.

The post starts with an overview of their pipeline flow (including a graphic) showing the different stages and the steps involved in each. It then moves on to the setup of Gitlab's CI functionality using a local Gitlab runner to run the pipeline. It covers some of the issues around CPU load using Docker. Next it shares the configurations for the different stages in the flow and decisions they had to make around building assets, dependencies and caching.

tagged: tutorial laravel application gitlab gitlabci continuous integration setup pipeline

Link: https://ohdear.app/blog/our-gitlab-ci-pipeline-for-laravel-applications

Laravel News:
Global Application Settings
Nov 28, 2018 @ 17:52:56

In a recent post to the Laravel News site, there's a post showing how to make use of a PHP package for storing and retrieving global settings that are then store them locally on the filesystem as a JSON-formatted document.

In applications it is often useful to have a way to store some global settings. These settings are not related to a specific model, such as a user, but to the system as a whole. You can achieve this with Eloquent, of course, but I never felt that was the right approach given you are saving non-relational data in a relational system. I found Spatie’s Valuestore package to be the perfect fit for creating a settings repository for an application.

The package will take your settings and store them as a JSON file on the local filesystem. Let’s use the example of having a banner notification at the top of your application. The banner notification is visible on every page and an admin can update the text it contains.

The tutorial walks you through the installation of the package via Composer and how to create the initial Valuestore instance, pointing it to a file on the local disk. It includes sample code showing how to push and pull values from the store including in your Blade templates. The tutorial also shows the binding of the store to the container and how to define it as a global helper.

tagged: tutorial application settings json store

Link: https://laravel-news.com/global-application-settings

Tomas Votruba:
When You Should Use Monorepo and When Local Packages
Nov 20, 2018 @ 15: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 @ 15: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 @ 14: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 @ 15: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 @ 14: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 @ 16: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 @ 14: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 @ 19: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


Trending Topics: