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

Adelf's Blog:
Are you sure you need entrust or laravel-permission to implement your authorization?
Nov 07, 2018 @ 15:33:19

In a post to his site Adelf aims to help you answer the question of the use of either the Entrust or Laravel-permission packages in your Laravel application to handle your authorization.

"Hmmm, I need some basic authorization, like admin role for admin panel and maybe some editor/moderator role... Let's google it. Wow! Laravel already has packages for that! zizaco/entrust, spatie/laravel-permission and others! Let's choose one!"

That's how it usually happens. Then package's migration will add about 5 tables to store roles, permissions and their relations. [...] It only looks simple: just install package, run ready migration and go on. From long-term point of view for 90% projects it's not the best choice.

He starts with an example of a common situation for most web developers: the inclusion of the package, the database changes that come with it and the management of keeping the permissions in sync. He makes the suggestion that maybe this seemingly "simple" way may not be the best and that, in most cases, they're overkill for what an application needs. He shows how to slim down this functionality using Laravel's own gates/policies and boil it down to just the checks that need to be made without the package overhead.

tagged: tutorial laravel permission entrust package requirement simple

Link: https://adelf.pro/2018/authorization-packages

Laravel News:
5 Laravel Helpers to Make Your Life Easier
Feb 22, 2018 @ 15:45:32

On the Laravel News site they've posted a new article with a listing of five useful helpers that come standard as a part of the Laravel framework.

There are a ton of helper methods in Laravel that make development more efficient. If you work with the framework, I encourage you to see what helpers you can introduce in your day-to-day work. In this blog post, I’d like to point out a few of my favorites.

The list in the post includes helpers for locating information in an array, pluralizing strings, throwing exceptions based on conditions and accessing object property values. For each item on the list there's a brief explanation and some sample code showing it in action (and what the result ends up being). The post finishes up by linking you over to the helpers page of the Laravel manual for more information and other handy functions to help reduce your own development time.

tagged: laravel helper simple top5 list example code

Link: https://laravel-news.com/5-laravel-helpers-make-life-easier

StarTutorial.com:
Understanding Design Patterns - Simple Factory
Feb 19, 2018 @ 18:38:43

On the StarTutorial.com site, they've posted the latest in their article series covering design patterns and their implementation in PHP. In this latest tutorial they cover the simple factory pattern. To help illustrate the point of the pattern they use an example of a toy company with an ever-expanding line of toys.

Dragon Inc. is one of the top toy manufacturers in China. In fact, they're a pioneer in toy manufacturing. They started production at a time when few toys were being produced commercially. Hence, they dominated the market and became the leader in the toy production industry.

The initial version of their produceToy method only had to worry about toy cars and helicopters. As their line expanded, it needed to be updated for "jumping frogs" too. Adding each new toy to the single function would be difficult to maintain but the simple factory pattern came to the rescue. It allowed for the abstraction of the toy object creation out to other handling and other objects, breaking the functionality up in accordance with the Single Responsibility Principle.

tagged: tutorial designpattern simple factory series toy

Link: https://www.startutorial.com/articles/view/understanding-design-patterns-simple-factory

Cees-Jan Kiewiet:
Extending ReactPHP's Child Processes
Jul 05, 2017 @ 16:49:59

In a new post to his site Cees-Jan Kiewiet walks you through the process to extend the ReactPHP project's child process handling (the first part of a series of posts).

react/child-process is very flexible and can work a lot of ways but sometimes you don't want to be bothered with the details of how it works and just want a simpler API to do that.

He then covers two packages where he used this "simpler is better" mentality and wrapped the current ReactPHP handling in a simpler API: one for defining "promises" on the child process and the other handles the messaging between the child and parent processes. He includes code examples for each of these, showing them in use to create simple operations.

tagged: reactpph child process extend custom api simple tutorial

Link: https://blog.wyrihaximus.net/2017/06/extending-react-child-process-part-one/

Sergey Zhuk:
Build A Simple Chat With ReactPHP Socket: Server
Jun 28, 2017 @ 15:46:39

Sergey Zhuk has a new post to his site showing how you can use ReactPHP's socket component to build a simple chat service as a server runing on a remote port.

In this article, we are going to build a simple chat server based on ReactPHP Socket Component. With this component, we can build simple async, streaming plaintext TCP/IP or a secure TLS socket server.

There are client and server sockets. The server is bound to a specific port number and just waits listening on this port. The client knows the host of the server and the port on which the server is listening. When the connection between server and client is established, the data exchange begins.

He then gets into the code required to make the server and add in some additional functionality. He starts by creating the server to listen for incoming connections and has it write back a simple message to prove it's working correctly. He then moves on to the code required for sending and receiving data. This initial version just echoes back what the user submits. He takes this an expands it out to start on the intiial steps of the chat system - creating the connection pool for multiple clients, storing usernames of those connected and using that information when transmitting a message to all clients connected.

tagged: simple reactphp chat server tutorial server client username

Link: http://seregazhuk.github.io/2017/06/22/reactphp-chat-server/

Cloudways Blog:
Create A Contact Form In Laravel That Sends You An Email
Jun 23, 2017 @ 16:17:02

On the Cloudways blog they've posted a tutorial showing you how to create a simple contact form that emails when someone fills it out and the information they submitted.

Laravel is well known for providing multiple solutions for a problem. This is one of the main reasons of the popularity of the framework. Popular Laravel solutions cover routine functionality such as authentication, sessions, routing, and caching.

Contact Us forms are another routine functionality that is a requirement of more or less every website. In this article, I am going to demonstrate how you can easily create a contact form in Laravel with email. To understand the functionality of Laravel mail function. I suggest you read my previous article on sending emails in Laravel.

The author then walks you through the installation of a new Laravel application on the Cloudways service. He then shows how to install the "Form" package (laravelcollective/html) and enable it as a service provider. Next up comes the database configuration and the creation of the table to handle the data submitted via the "Contact Us" form. The model is then created to work with the table, the route is added to show the form (and handle the submission) as well as the matching view and controller. The post wraps up with the commands and configuration you'll need to send the emails and an example of a "mailable" class to handle the email's construction.

tagged: tutorial laravel contact form email simple

Link: https://www.cloudways.com/blog/laravel-contact-form/

TutsPlus.com:
Dynamic Page Templates in WordPress, Part 3
Jun 19, 2017 @ 15:45:04

The TutsPlus.com site has posted the third part of their "Dynamic Page Templates in WordPress" tutorial series today. In this latest article author David Gwyer finishes off the series using all that they've shared from part one and part two to create two examples.

In the first two parts of this tutorial series, we covered what dynamic page templates were and why they were needed. We also looked at the code required to implement them.

In this third and final tutorial in the series, I'll be creating two examples of fully working dynamic page templates you can use in your own projects. These were specifically chosen to be easily extendable to suit your own needs, and are intended as inspiration for any other type of dynamic page templates you can think of.

He then walks you through the creation of the two page templates: a Simple Contact Form and a Blog Post Archive. The first allows you to dynamically control the form elements for a UI interface (rather than code) and the second uses dynamic data to display the list of previous blog posts. The tutorial then finishes with a look at how, since WordPress 4.7, you can use dynamic page templates with any kind of post, not just pages.

tagged: wordpress series part3 dynamic page template blog archive simple form tutorial

Link: https://code.tutsplus.com/tutorials/dynamic-page-templates-in-wordpress-part-3--cms-28514

Laravel News:
Zttp is a Wrapper Around Guzzle for Simplifying Common Use Cases
May 30, 2017 @ 15:25:45

On the Laravel News site they've introduced a package from Adam Wathan that cam help simplify the use of the popular Guzzle package for making HTTP requests. Zhttp is a wrapper around Guzzle and tries to make the code to make the requests simpler and easier to follow.

Zttp is a new PHP package by Adam Wathan that is a Guzzle wrapper designed to bring an expressive syntax and simplify common use cases. [...] Zttp simplifies the code to make the request and automatically returns the JSON response.

A few other examples of requests using the tool are provided: POSTing with parameters, sending a PATCH/PUT request, adding an Accept header and how to prevent the request from following redirects. You can find out more on the project's GitHub repository and grab the latest release to try out in your own code.

tagged: guzzle http wrapper simple common usecase zhttp

Link: https://laravel-news.com/zttp-guzzle-wrapper

Dac Chartrand:
Building a Simple API using Opulence PHP
Jan 30, 2017 @ 17:27:35

Dac Chartrand has written up a post to his site showing you how to create a simple REST API with Opulence, a PHP framework that bills itself as a "modern framework for modern PHP".

This tutorial will show you how to code a simple JSON API using Opulence PHP. We will install Opulence’s skeleton project using composer, then create a ‘user’ database entity, and finally we will match CRUD (Create, Read, Update, Delete) to POST, GET, PUT, and DELETE.

The start of the tutorial helps you get a new Opulence project set up and running including updating the configuration for content type handling and the database connection details. With that set up he moves into the code creating the "User" entity and its matching classes. He builds out the controller, selecting a REST controller from the options and builds out all methods needed for the CRUD user operations. The tutorial finishes with a bit of testing information so you can see the framework in action.

tagged: opulence api rest tutorial simple user framework

Link: http://kizu514.com/blog/building-a-simple-api-using-opulence-php/

Jason McCreary:
Update PHP on Mac OS X
Sep 20, 2016 @ 15:15:26

Jason McCreary has posted an update to his guide for installing PHP on Mac OS X and replacing the version of PHP that comes with El Capitan (5.5) with a handy package manager more specific to PHP installations.

As noted in my posts on Installing Apache, PHP and MySQL on Mac OS X, OS X comes pre-installed with Apache and PHP. Unfortunately, as of Mac OS X 10.11 (El Capitan) the pre-installed version of PHP is still 5.5. As PHP 5.5 has reached end of life, I imagine the pre-installed version of PHP will be updated with Mac OS 10.12 (Sierra). However, it may only be PHP 5.6.

So what do you do if you want to upgrade or install a different PHP version on your Mac? Well, you could use Homebrew. But I found a pre-packaged alternative - PHP OSX.

With this package manager, the installation is only a few steps but he lists them out with a bit more detail to help you understand what's happening:

  • Installing PHP (your choice of version)
  • Configuring Apache (loading the php5 shared module)
  • Updating your PATH
  • Configuring PHP
tagged: osx update language version package simple installation tutorial

Link: http://jason.pureconcepts.net/2016/09/upgrade-php-mac-os-x/


Trending Topics: