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

TutsPlus.com:
Building With the Twitter API: Creating Friends to Follow
Mar 23, 2017 @ 12:32:04

The TutsPlus.com site has posted the latest tutorial in their "Building with the Twitter API" series showing how to, in a Yii2 application, automatically add friends to a Twitter account via the Twitter API. You've probably seen this in several services that offer suggestions of followers to add to your list.

Today I'll guide you through using the Yii2 Framework for PHP to access the Twitter API and automate adding friends to people's Twitter accounts. (If you'd like to learn more about Yii2, check out our parallel series Programming With Yii2.)

And, I've created a website, Twixxr.com, which will let you demonstrate the feature by adding prominent women on Twitter for your account to follow.

The tutorial starts with links to some of the other Twitter tutorials that have been posted in the past and how things have evolved to make it easier in a Yii2 application. He starts by helping you get the Twitter OAuth PHP Library installed and lists some of the goals of the end result. The code is included to authorize the user and handle the callback once they've approved the app in the normal OAuth flow. It then shows how to connect via the API using that user's information, load profiles for the suggested users and link them as a friend. The tutorial finishes with a look at performance and a bit of code used to handle the backend processing of the request instead of performing it in real time.

tagged: twitter tutorial api oauth2 friends follow suggestion yii2

Link: https://code.tutsplus.com/tutorials/building-with-the-twitter-api-creating-friends-to-follow--cms-27492

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

Cloudways Blog:
User Authentication In Yii2 With Email Verification
Mar 13, 2017 @ 13:54:47

The Cloudways blog has a new tutorial posted showing you how to set up a system for user authentication via email in a Yii2-based application. The concepts would be the same in just about any other framework, it's just the code to implement it would be slightly different.

User authentication is an essential component of every web app. Whether it is a simple to-do list or a complex corporate portal, user authentication remains a common factor across all types of PHP applications.

[...] In this tutorial, I will show you how to develop a user authentication component in Yii2 that features a SMTP email verification. If you are new to Yii2, you must first read previous tutorials to get an introduction to Yii2. Next read about form handling in Yii 2 and database management in Yii 2.

The tutorial makes use of this extension for the traditional user handling as a more flexible option than the built-in framework features. They then walk you through the process of creating the new Yii2 project and getting the component installed. It also helps you:

  • run the migrations to create the required tables
  • set up the SMTP mailer
  • update the navigation with the links for logged in/logged out users
  • configuring the email settings

The end result is a signup form that, when submitted will send an email to the user's email address to verify it and allow the user to continue the registration process.

tagged: user authentication yii2 framework tutorial signup package

Link: https://www.cloudways.com/blog/user-authentication-yii2/

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

TutsPlus.com:
Building Your Startup: Requesting Scheduling Changes
Feb 07, 2017 @ 12:44:23

The TutsPlus.com site has continued their "Building Your Startup" series with this new article enhancing the application they've already created to send requests for scheduling changes.

As the Meeting Planner alpha testing phase began, the clearest feature gap was the inability to change a meeting after it had been scheduled. It's not an easy problem. Is it okay to just change a meeting without a participant's permission? Or should you ask? Or do either, depending on your role in organizing the meeting? What if you just want to ask if it's okay to meet 15 minutes later—that should be easy, right?

Solving all this required some reflecting on the social aspects of adjusting a meeting. Over time, I realized that the ability to adjust meetings easily after they've been scheduled could make or break the Meeting Planner brand.

He then starts out by describing the "tall mountain to climb" in the number of changes to backend, frontend and UX/UI functionality required to add the feature. He includes all of the code changes and additions that need to be made including:

  • migrations to add new tables
  • UI updates to add options for rescheduling requests
  • form changes
  • handling request submissions

Each point on the list includes code, screenshots and anything else that was required to make the update.

tagged: startup build scheduling change yii2 tutorial ui backend frontend

Link: https://code.tutsplus.com/tutorials/building-your-startup-requesting-scheduling-changes--cms-27076

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

TutsPlus.com:
Programming With Yii2: Using the Debugger
Jan 03, 2017 @ 11:52:29

The TutsPlus.com site continues their "Programming with Yii2" series of tutorials with the latest edition in the series, a look at using the Yii2 debugger to help track down issues in your code.

In today's tutorial, I'll show you how to install the Yii2 Debugger, and we'll explore its capabilities in detail. It's a powerful programming assistant which is often underutilized.

As you code and test your application, the debugger can show you your application path, queries and query variables, performance characteristics, server and framework settings, and much more.

The article starts off by showing you how to install the "yiisoft/yii2-debug" library (via Composer) and enable it in the "debug" section of your configuration. With it correctly installed you'll then be able to access it at the bottom of your pages. The debug console provides plenty of helpful information related to:

  • the route matched
  • a log of actions and events
  • load time
  • memory used
  • database queries performed

...among others. The tutorial walks you through these and other pieces of information the tool provides with screenshots of example output for each.

tagged: programming yii2 debugger tutorial series toolbar screenshot detail

Link: https://code.tutsplus.com/tutorials/programming-with-yii2-using-the-debugger--cms-26910

TutsPlus.com:
Programming With Yii2: Helpers
Dec 27, 2016 @ 11:13:44

The TutsPlus.com site has continued their "Programming with Yii2" tutorial series with a new post introducing you to helper functions that come bundled with the framework. It also shows you how to create your own custom helper function, making it easier to perform common functions custom to your application.

In the Programming With Yii2 series, I'm guiding readers in use of the Yii2 Framework for PHP. In this tutorial, I'll provide a brief overview of helpers. In Yii, helpers are modules which group commonly useful libraries for string, file, image, URL and HTML management amongst other things, and they are easy to extend.

I'll also share an example of creating a helper within Meeting Planner, the focus of our Envato Tuts+ startup series.

The tutorial then introduces you to (and links you to) the common helpers the framework comes bundled with including the ArrayHelper, FileHelper and Markdown helpers. The tutorial then covers two in a bit more detail, the ArrayHelper and HtmlPurifier helper, including some code examples for each. Finally it shows the creation of a custom helper with several custom functions and their use in a template.

tagged: programming series yii2 framework helpers custom tutorial

Link: https://code.tutsplus.com/tutorials/programming-with-yii2-helpers--cms-26889

TutsPlus.com:
Building Your Startup: Security Basics
Dec 20, 2016 @ 11:55:58

The TutsPlus.com site has continued their "Building Your Startup" tutorial series with this latest article covering the "security basics" you'll need to adequately protect your application. This tutorial touches on both the server-level and code-level security aspects.

In today's episode, we'll dive into the basics of web server security. I'll cover securing the Linux VPS running Meeting Planner and some basic Yii security. In the next episode, I'll dive more into programmatic Yii application security.

The article starts off with the server side of things, introducing hosting options, keeping the server updated, configuring SSH for logins, setting up a firewall and SSL. With that solid base in place, it then starts on the code side covering the built-in functionality used to secure the backend and frontend functionality.

tagged: tutorial series yii2 startup security basics server code

Link: https://code.tutsplus.com/tutorials/building-your-startup-security-basics--cms-26702