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

Esben Petersen:
A modern REST API in Laravel 5 Part 4: Authentication using Laravel Passport
Mar 20, 2017 @ 10:56:15

Esben Petersen has posted the fourth part of his tutorial series covering the creation of a "modern REST API" with Laravel. In this latest article he focuses on authenticating users with the help of an OAuth2 flow.

OAuth is all around us. Most of us have tried to login to a 3rd party service using our Facebook or Google account as a login. This login mechanism is one of many OAuth authentication types. However, you can also use OAuth to generate simple API keys. One of the OAuth authentication types generates API keys based on username and password and is therefore a solid authentication choice for SaaS-style apps. This article will explore how to setup the password grant authentication type in Laravel using Laravel Passport.

The article is broken up into a few different sections, each with explanations and code where appropriate to help illustrate the point:

  • a basic introduction to OAuth2 and grants
  • authentication in single-page applications
  • dependencies to use (and install/configuration)
  • creating the login proxy
  • building a consumer

The final step is an example (using a curl command) to test the API and ensure things are working as expected. The post ends with a more "real world" example of a Slack-style application and linking channels and user but only showing the channels users have access to based on scope.

tagged: tutorial rest api laravel series part4 oauth2 passport

Link: http://esbenp.github.io/2017/03/19/modern-rest-api-laravel-part-4/

TutsPlus.com:
Building Your Startup: Running Multiple Domains
Mar 17, 2017 @ 10:53:11

The TutsPlus.com site has posted their latest tutorial in their "Building Your Startup" series today. In this new article they show you how to update the application to support multiple domains in one Yii2 application.

The Yii2 advanced template allows you to run a number of sites in one code tree. I used its front-end tree to build Meeting Planner and its back-end tree to build the administrative suite of tools for the service. Today, however, I'll focus on launching another domain on top of the existing front-end tree—and all the small and large complexities that go along with this.

[...] I presumed it would be fairly simple (no pun intended) to launch Simple Planner, but it ended up taking a few days of work.

He points out that the work to get the frontend of the application working with a different domain name was relatively simple. It was the update to the email handling that took the most time (the application is very email-driven). He then shows the configuration changes required to add multiple domains, how to change the homepage for each domain and update images/links/etc to match the new domain. He then moves on to configuring the services used for each domain and, finally, the pieces that need to be updated to have the emails support the multiple domains.

tagged: startup build tutorial series yii2 multiple domain

Link: https://code.tutsplus.com/tutorials/building-your-startup-running-multiple-domains--cms-27459

TutsPlus.com:
How to Program With Yii2: ActiveRecord
Mar 09, 2017 @ 12:07:53

In the latest tutorial in their "Programming with Yii2" series the TutsPlus.com site shows you how to work with the ActiveRecord functionality included with the framework.

In this Programming With Yii2 series, I'm guiding readers in use of the Yii2 Framework for PHP. In today's tutorial, I'll walk you through using Yii's object-relational mapping, known as ORM, for working with databases. It's called Active Record and is a key aspect of programming database applications efficiently in Yii.

Yii offers different ways to work with your database programmatically, such as direct queries and a query builder, but using Active Record offers a complete set of benefits for object-oriented database programming.

The article goes on from there and defines some of the basics around what Active Record is and how it works. It then starts on the code, showing how to create an ActiveRecord model and execute queries to:

  • locate single or multiple records
  • build queries
  • counting records
  • and accessing the records returned

They also talk about mass assignment, saving data via model instances, deleting records and creating relationships between the models.

tagged: yii2 framework series activerecord database tutorial introduction

Link: https://code.tutsplus.com/tutorials/how-to-program-with-yii2-active-record--cms-27434

Esben Petersen:
A modern REST API in Laravel 5 Part 1: Structure
Mar 09, 2017 @ 10:44:56

Esben Petersen has kicked off his series on creating a modern REST framework in Laravel 5 with part one in the series. This first tutorial focuses on the setup of the application using a "folders by component" approach.

Over time when your API grows in size it also grows in complexity. Many moving parts work together in order for it to function. If you do not employ a scaleable structure you will have a hard time maintaining your API. New additions will cause side effects and breakage in other places etc.

It is important to realize in software development no singular structure is the mother of all structures. It is important to build a toolbox of patterns which you can employ given different situations. This article will serve as an opinionated piece on how such a structure could look.

The tutorial covers structure on three different levels (patterns): application flow, project folder structure and resource folder structure. For each level they cover some of the basic concepts involved and share code showing how it could be implemented including controllers, repositories, middleware and fitting it all into a a resource folder structure.

tagged: laravel rest api laravel5 tutorial series part1 structure

Link: http://esbenp.github.io/2016/04/11/modern-rest-api-laravel-part-1/

Delicious Brains Blog:
Hosting WordPress Yourself 2017 Update
Mar 01, 2017 @ 10:10:26

The Delicious Brains site has posted the latest part in their "Hosting WordPress Yourself" series (originally started back in 2015). In this latest tutorial they update things based on the current status of the WordPress project and share some of the considerations that need to be made when self-hosting versus something like WordPress.com.

It’s been 2 years since I started writing the Hosting WordPress Yourself series, and in that time a lot has changed! If you had tried following along with the series recently you will probably have noticed that a few of the steps outlined in the articles no longer worked, or were no longer relevant. A few exciting new technologies and services have also been introduced over the last few years (e.g. PHP 7.1, Let’s Encrypt, HTTP/2) which can improve both the performance and security of your sites. As such, Brad suggested that I update the entire series to reflect what’s changed over the last couple of years.

The existing articles in this series have already been updated with the changes that follow. This article serves as a changelog and documents what’s changed in each article.

They then go through the major updates that need to be made to the previous advice covering including topics like:

  • Setting Up a Virtual Server
  • Installing Nginx, PHP and MariaDB
  • Server Monitoring and Caching
  • Cron, Email and Automatic Backups
  • Nginx Security Tweaks, WooCommerce Caching, and Auto Server Updates

Check out the full post for the complete advice.

tagged: hosting wordpress update 2017 tutorial series part8

Link: https://deliciousbrains.com/hosting-wordpress-2017-update/

AWS Developer Blog:
Automating the Deployment of Encrypted Web Services with the AWS SDK for PHP (Pa
Feb 17, 2017 @ 12:25:48

The Amazon Web Services blog has posted the second part of their series covering the automated deployment of encrypted web services with the AWS SDK. In this new tutorial (part two, part one is here) they continue with the deployment of services: AWS Elastic Beanstalk, Amazon Route 53 and Amazon CloudFront.

In the first post of this series, we focused on how to use Amazon Route 53 for domain registration and use Amazon Certificate Manager (ACM) to create SSL certificates. With our newly registered domain available for use, we can proceed to deploy and configure the services we need to host the www.dev-null.link website across an encrypted connection. Once complete, the infrastructure configuration will reflect the diagrams [included in the post].

The tutorial then walks you through each of the services you need to deploy and shares the code (using the AWS PHP SDK) to show how to automate the process. There's also a few screenshots included of various page results and admin UIs to help you be sure you're in the right place.

tagged: aws amazon deployment encrypted webservice sdk tutorial series part2

Link: https://aws.amazon.com/blogs/developer/automating-the-deployment-of-encrypted-web-services-with-the-aws-sdk-for-php-part-2/

Delicious Brains Blog:
Scaling Laravel Using AWS Elastic Beanstalk Part 3: Setting up Elastic Beanst
Feb 07, 2017 @ 10:29:41

The Delicious Brains blog has posted the third part of their series covering the scaling of Laravel with AWS Beanstalk. In this latest article the walk through the setup of the Elastic Beanstalk application.

In my last article we set up the supporting services we would require for our Laravel app once we deploy it to the Elastic Beanstalk architecture. We created a VPC to keep our infrastructure secure, we created a MySQL database in RDS, and we set up ElastiCache for our Redis cache. So now that our Laravel app is decoupled and our supporting services are in place, it’s finally time to deploy our app to Elastic Beanstalk.

They start by talking about the Elastic Beanstalk environments and helping you get the application set up via the command line tool. Next up is the creation of the ebextensions directory and the matching YAML configurations for the EB settings. They provide an example of the contents` and explain what some of the configuration sets up. Finally they use the command line tool to issue the "create" command and build out the environment based on the configuration. The post wraps up with a bit about some configuration tweaks that could be made and optionally enabling HTTPS.

tagged: tutorial elastic beanstalk tutorial series part3 setup environment commandline

Link: https://deliciousbrains.com/scaling-laravel-using-aws-elastic-beanstalk-part-3-setting-elastic-beanstalk/

TutsPlus.com:
Building Your Startup: Advanced Scheduling Commands
Jan 30, 2017 @ 10:56:17

The TutsPlus.com site has updated their "Building Your Startup" series with their latest tutorial showing you how to build advanced scheduling commands allowing for things like repeating meetings, updating the meeting details and rescheduling.

I also began to realize that the ability to adjust meetings easily after they've been scheduled could make or break the Meeting Planner brand. [...] In today's tutorial, I'll cover expanding the navigation bar using Bootstrap and the basics of building some of the advanced scheduling features within Meeting Planner. Next week, I'll review building the more complex feature for participants to request change(s) and for others to accept or decline them.

He starts with the frontend, updating the navigation bar to include links to other functionality for meeting changes, repeating and showing planning activities for the meeting. He uses Bootstrap's single-button dropdowns for this and includes the code to add them to the UI with a bit of code in the view. He then gets into the main functionality of these changes showing the code to:

  • make changes to a current meeting
  • reschedule a meeting
  • repeat a meeting
  • resend invitations

The next part in the series will take a look into social engineering and UX needs for the application along with some other smaller changes.

tagged: startup tutorial series advanced scheduling commands change update meeting

Link: https://code.tutsplus.com/tutorials/building-your-startup-advanced-scheduling-commands--cms-27075

NetTuts.com:
Building Your Startup: Automatic Time-Zone Detection
Jan 25, 2017 @ 12:43:43

The TutsPlus.com site continues their "Building Your Startup" series of tutorials with the latest in the series covering automatic timezone detection based on the user's local time.

For the alpha release of Meeting Planner, I provided people the opportunity to change their time zone in user settings. However, for anyone outside of the western United States, they may have been wondering why their calendar appointments were at the wrong times. You have to know to look for the settings page.

As I approach the beta, I realized I needed to fix this as soon as possible. So I began to reflect on how best to resolve this. In today's episode, I'm going to walk you through my approach to automatic time-zone detection and how I integrated it into the user experience.

The tutorial starts off with a look at the current state of timezone detection, linking to two options that do mostly the same thing. Eventually, however, he decided on the jsTimezoneDetect library as it fit best with the needs of the application. He covers some of the thoughts that went into designing the user experience and the code required to integrate the Javascript library with his Yii2-based application. He ends the tutorial with a few additional considerations worth keeping in mind including timezone representation in ical exports and virtual meetings.

tagged: timezone detection tutorial startup series yii2 automatic

Link: https://code.tutsplus.com/tutorials/building-your-startup-automatic-timezone-detection--cms-27041

TutsPlus.com:
Building Your Startup: Preparing for Text Messaging
Jan 23, 2017 @ 09:44:52

The TutsPlus.com site has posted the latest in their (lengthy) series of tutorials showing how to use PHP to "build your startup". In this new tutorial they show how to integrate SMS functionality into the application. This is the first part covering this topic and mostly covers the setup and testing of the connection to send the necessary SMS messages.

In today's episode, I'm going to walk you through the first half of my SMS configuration for the Meeting Planner application. Basically, I'll cover choosing an SMS provider, setting up the account, building the initial application infrastructure, and trial texting.

In the next episode, I'll build specific texting scenarios into the Meeting Planner application and walk you through those decisions and the coding that followed.

He starts off talking about one of the main choices you'll have to make early on: which SMS provider you want to use to send your messages. While they list several, for the sake of the tutorial they move ahead with Twilio. He show you how to set up an account with the Twilio service and where to get the credentials to connect your application to their API. After talking a bit about things like SMS pricing and handling incoming messages he starts on the integration with Yii2 via this package. Once installed and configured he creates a simple class to send a message via Twilio and tries it out with a "First test" message.

tagged: startup build tutorial series yii2 framework twilio sms notification

Link: https://code.tutsplus.com/tutorials/building-your-startup-preparing-for-text-messaging--cms-26912