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

DeliciousBrains.com:
PHP Encryption Methods for Passwords & Other Sensitive Data
Sep 19, 2018 @ 14:20:39

On the Delicious Brains site, there's a new tutorial posted sharing some of the methods included with PHP to improve protection of sensitive data using encryption.

I recently attended Laracon EU 2018 where Marcus Bointon gave a great talk on Crypto in PHP 7.2. I left the talk having a much greater appreciation for how vastly complicated cryptography is, but also for how PHP is making encryption more accessible thanks to the introduction of Sodium. Data encryption in PHP is something I’ve been working on as part of my work on SpinupWP so I thought it was time I shared a few insights. Buckle up, because this could be a bumpy ride!

The author then spends the remainder of the article covering the different types of encryption that are included with recent versions of the PHP language:

  • one-way hashing (such as the bcrypt password hashing functionality)
  • secret key encryption (symmetric)
  • envelope encryption (such as Google's KMS)

Code examples are provided to show each of the types in action and links are also included for more information on several related topics/resources.

tagged: encryption tutorial hashing symmetric envelope kms google

Link: https://deliciousbrains.com/php-encryption-methods/

Matt Allan:
Writing Protobuf Services in PHP
Jan 29, 2018 @ 16:56:12

Matt Allan has a new post to his site sharing some of his experience in using PHP to write Protobuf services. Protobuf (short for "protocol buffers") are a language-agnostic data structure that allows for easy serialization.

Lately I’ve been investigating Protobuf as a replacement for JSON RPC services. If you aren’t familiar with Protobuf, it’s a language neutral serialization format from Google. It’s most commonly associated with Google’s RPC framework gRPC but it can be used standalone too. In this guide we are going to build a simple calculator RPC service using nothing but the Protobuf compiler and PHP.

The post starts by creating a ".proto" file, defining the structure of the data to be consumed. He includes the definition for the service itself, showing how to define a basic "Calculator" service with "add" and "subtract" methods. From there he defines the request and response formats for the data. The definitions are then compiled and classes are generated from the definitions. Switching to the PHP side, he sets up Composer autoloading and pulls in the google/protobuf package. Next comes the PHP code to work with the service and serving it up via the built-in server. Finally, he shares the code to create a client for the service and uses it to make some requests.

tagged: protobuf service protocolbuffer google tutorial webservice

Link: http://mattallan.org/posts/protobuf-php-services/

Phillip Shipley:
Read and write Google Sheets from PHP
Jun 01, 2017 @ 15:57:44

Phillip Shipley has written up a post for his site walking you through the process of using PHP to read from and write to Google Sheets via the Google Sheets API.

This past week I needed to be able to read some data from a Google Sheet and then update a column for each row after processing it. This sort of thing should be simple, Google is built on APIs and has client SDKs for just about every language. I’ve also integrated with several Google Admin APIs previously so I expected this to be a breeze. I was wrong.

I started out by reading the Quickstart for Sheets API with the PHP Client, but almost immediately I could tell it was not written for my use case. [...] My use case is to use a backend process to function as a service account and batch process data. So the whole API credentials process was wrong for me.

He tried a few different approaches and finally, after some guessing, discovered how to share a sheet with the email address for the application. He then includes the steps to follow to get this same setup configured for your application and the code (using the Google_Client) to read and write to the sheet.

tagged: read write google sheets tutorial client sharing

Link: http://www.phillipshipley.com/2017/05/read-and-write-google-sheets-from-php/

SitePoint PHP Blog:
The Ultimate Guide to Deploying PHP Apps in the Cloud
May 12, 2017 @ 17:18:59

On the SitePoint PHP blog author Prosper Otemuyiwa shares what they call the ultimate guide to deploying PHP apps in the cloud with examples for Heroku, Google Cloud, IBM BlueMix, Microsoft Azure, Amazon Web Services and Laravel Forge.

There is a popular mantra amongst developers that goes like this write, test and deploy. In this tutorial, I’ll show you how to deploy your PHP apps to different cloud server platforms such as Google Cloud, Microsoft Azure, Heroku, IBM Bluemix, and others.

Cloud servers are basically virtual servers that run within a cloud computing environment. There are various benefits to hosting and deploying your applications in the cloud. [...] In fact, many companies have moved their infrastructure to the cloud in order to reduce cost and complexity. It’s a great option for small, mid-sized, and enterprise scale businesses. If you write a lot of tutorials and do POCs (Proof-of-concepts) like me, it’s also a great choice for you!

He starts off by covering the technologies that will be involved in each deploy: Linux, Apache, MySQL and of course PHP. Then, for each of the platforms previously mentioned, he goes through the setup and configuration of the same functionality. Most include screenshots of the UI in the service setting up the account and application. He also links to two tools that can make it easier to deploy your actual application to these newly configured cloud instances: Envoyer and Deployer.

tagged: guide deploy application cloud google bluemix azure aws forge

Link: https://www.sitepoint.com/ultimate-guide-deploying-php-apps-cloud/

Laravel News:
Using the Google API with Socialite
Apr 11, 2017 @ 14:47:36

On the Laravel News site there's a new tutorial posted showing you how to use the Socialite package with the Google API to connect a user's account and get a list of their contacts.

When I start a project that requires users to log in using their Google accounts, I immediately turned to Laravel Socialite. Socialite is one of Laravel’s official packages, but it is clear it only handles user authentication, making its use not as dynamic as I had hoped it would be. While I needed users to log in, I also needed to get a list of their Google Contacts. In this post, I’ll show you how I was able to query a list of contacts from Google’s People API and keep using Socialite.

They start with a basic guide to creating an application on the Google API Console and what information you'll need (credentials) to allow your application to connect. Then, using the Google API Client for PHP and the functionality built into Socialite they create the approval flow and how to handle refresh tokens should your token expire.

tagged: tutorial laravel socialite contacts google api token

Link: https://laravel-news.com/google-api-socialite

Sameer Borate:
Accessing Google Page Insights in PHP
Mar 21, 2017 @ 14:45:12

On his site today Sameer Borate shares a tutorial showing you how to access Google Insights data via your PHP application with the help of the dsentker/phpinsights package.

Google Page Insights is a required tool to have when analyzing the speed and usability of your site. As you may know these metrics influence how google ranks your page in search results. If you frequently make changes to your web site designs than it becomes mandatory to check the metrics after each change to make sure that the design changes has not affected the score in any negative way. If you have many pages to test than manual testing can quickly become cumbersome.

Thankfully there are libraries that you can use to automate this process. Once such is given in this post which allows you to get Google Page Insight metrics using PHP.

He then walks you through the installation of the package (via Composer) and how to use it, along with your Google API key, to fetch the information for a given URL. You can get information for different environments (desktop vs mobile) and even a screenshot of the page that's under test. He ends the post with a helpful hint for those that might get a certificate error when making the request and how to fix it.

tagged: google insights data tutorial package install usage

Link: http://www.codediesel.com/api/accessing-google-page-insights-php/

Twilio Blog:
Google Spreadsheets and PHP
Mar 08, 2017 @ 15:48:31

On the Twilio blog they've posted an article from Matt Stauffer looking at the combination of Google Sheets and PHP to perform some of the normal CRUD (create, read, update, delete) operations via the Google Sheets API.

Have you ever needed to pull some data from a Google Spreadsheet? My default in the past would be to export the data and upload it to the app directly, but it turns out it’s not very difficult to read directly from Google Spreadsheets using the Google Drive API.

In this tutorial, we’ll read, write, update, and delete data from a Google Spreadsheet with just a few lines of PHP.

He clones an example spreadsheet to use in the tutorial and shows how to prepare it for programatic access (basically exposing it for use). He then gets to work using the google/apiclient and asimlqt/php-google-spreadsheet-client packages to connect to and work with the API. He includes the code to:

  • connect to the API and get a usable token
  • pull data from the sheet by title
  • update individual cells data
  • updating entire rows
  • deleting rows
  • insert new rows

You'll need to be a bit familiar with how the Google API Console works to get things set up, but there's an animation that helps walk you through some of it.

tagged: google sheets tutorial package api crud operation console

Link: https://www.twilio.com/blog/2017/03/google-spreadsheets-and-php.html

SitePoint PHP Blog:
Calendar as a Service in PHP? Easy, with Google Calendar API!
Jan 26, 2017 @ 16:25:21

On the SitePoint PHP blog there's a new tutorial posted by Wern Ancheta showing you how to offer "calendar as a service" in your application with the help of the Google Calendar API. The Calendar API provides access to all of the features you'd expect from the Google Calendar system and the tutorial helps you make a fully functional overlay integrated with it and living in your application.

In this article, you’ll learn how to work with the Google Calendar API in PHP. You’ll do it by building a calendar app that allows users to add new calendars, add events, and sync calendars to Google Calendar.

The tutorial then walks you through every step of the process you'll need to get your application hooked into the API and the code to use for the integration:

  • Setting up a Google Console Project
  • Building the App
  • Configuring the App
  • Creating a Service Container for the Google Client
  • (Adding) Routes
  • Admin Route Middleware
  • Database setup
  • Home Pages creation
  • Admin Pages creation
  • Creating a Calendar
  • Creating an Event
  • Syncing a Calendar
  • Listing Events
  • Logging Out

The application they create is Laravel based and makes use of a bit of Javascript in the views for the date selector and handlebars templating.

tagged: calendar api google service tutorial laravel jquery

Link: https://www.sitepoint.com/calendar-as-a-service-in-php-easy-with-google-calendar-api/

TutsPlus.com:
Programming With Yii2: Using Ajax
Nov 10, 2016 @ 17:18:23

The TutsPlus.com site continues their series covering development with the Yii2 framework in this new article. This time they're focusing in on only the Ajax functionality using it an an example for their startup application interacting with Google Maps to place meeting locations.

In this Programming With Yii2 series, I'm guiding readers in use of the Yii2 Framework for PHP. In this tutorial, we'll explore the implementation of interactive pages using Ajax. Specifically, I'm going to highlight the use of Ajax in two areas of the Meeting Planner application, which I'm writing the Building Your Startup series about in parallel.

The article then starts in on showing you how to load a Google Map into the page using some of the built-in Ajax handling and integrating it into the "Create a Place" form. They show how to collect the information from the map once a location is selected and use this to update a "meeting" record on the backend. All coded needed to reproduce the system is included.

tagged: ajax yii2 framework programming tutorial series google map

Link: https://code.tutsplus.com/tutorials/programming-with-yii2-using-ajax--cms-26663

SitePoint PHP Blog:
2FA in Laravel with Google Authenticator – Get Secure!
Nov 01, 2016 @ 15:47:02

On the SitePoint PHP blog there's a tutorial posted from Christopher Thomas showing you how to integrate two-factor authentication into your Laravel application with a Google Authenticator-compatible library, helping to secure your site even better than just one level of authentication and authorization.

In this tutorial, we will use Laravel and Google Authenticator to demonstrate how to implement 2FA in a webapp. Google Authenticator is just one implementation of the Time-Based One-Time Password (TOTP) algorithm, RFC 6238. This industry standard is used in a lot of various 2FA solutions.

[...] How the TOTP works is that the server generates a secret key. This secret key is then passed to the user. The secret key is used in combination with the current Unix timestamp to generate a six digit number, using a keyed-hash message authentication code (HMAC) based algorithm. This six digit number is the OTP. It changes every 30 seconds.

They start with a clean slate and build a new Laravel project out and include the libraries needed for the TFA support: pragmarx/google2fa and paragonie/constant_time_encoding. You then add in the provider to Laravel's config, build out the models/tables to hold the two-factor information and add a few routes to handle the validation steps. They also include the details in building out the controllers, updating the AuthController for the new step in the authentication flow and how to handle the code validation. The code for all of this (as well as the views) is included as well as screenshots showing the setup and usage of the two-factor handling in the standard authentication flow.

tagged: tutorial google authenticator security laravel twofactor authentication

Link: https://www.sitepoint.com/2fa-in-laravel-with-google-authenticator-get-secure/


Trending Topics: