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

Laravel News:
Building a Laravel Translation Package – Wiring Up The Frontend
Nov 16, 2018 @ 19:33:36

The Laravel News site has posted the latest in their "Building a Laravel Translation Package" series of tutorials with a new post focusing on the frontend and getting it connected to the backend functionality.

In the last installment of this series, we talked through the process of manipulating the translations in our application’s language files into a format where we are now in a position to start interacting with them. In this article, we’ll be wiring up the frontend ready to start building out the user interface which will aid users with the process of translation management.

The UI will be developed using the community favorites, Tailwind CSS and Vue.js.

The tutorial starts with the approach for the functionality, taking a more hybrid approach and using a balance of backend and frontend for the majority of the functionality. It then starts in on the technical parts to connect the two halves:

  • adding the required routes
  • creating the controllers
  • building out the views to render the interface

The majority of the post is then dedicated to the creation of the assets - the Javascript and CSS - to create the "framework" the functionality will use to work with the translations.

tagged: laravel tutorial series translation package backend frontend connect

Link: https://laravel-news.com/laravel-translation-package-frontend

Scotch.io:
Build A Telegram Bot with Laravel and BotMan
Mar 07, 2018 @ 16:17:49

On the Scotch.io site there's a tutorial posted showing you how to create a Telegram bot with BotMan the popular PHP package for creating chatbots.

Being a Scotch.io reader you definitely know that we have covered creating Bots before, we have quite few posts on Slack Bots, Twitter Bots and other related topics [...] But today, we have something different for you, today we will be creating a Telegram bot for dog lovers. Yes, you heard it right. A Telegram Bot for dog lovers using Dog API.

The tutorial then walks through the entire process of getting the bot up and running including:

  • Installation of Laravel and BotMan
  • Creating the commands and testing the bot
  • Installing the Telegram driver and creating the bot
  • Using ngrok to allow external calls to come into your internal application

The post finishes by showing how to link your bot to Telegram and test it out using messages to send you random dog pictures when requested.

tagged: scotchio telegram bot botman tutorial setup configure connect

Link: https://scotch.io/tutorials/build-a-telegram-bot-with-laravel-and-botman

IBM Developer Blog:
Get Started With CouchDB Using PHP and Guzzle
Jul 28, 2016 @ 18:07:48

On the IBM Developer Blog they've posted a new article from Lorna Mitchell helping you get started with CouchDB and Guzzle, making use of this popular HTTP client package to interface with CouchDB's HTTP interface quickly and easily.

In today’s post, we’ll look at how we can use CouchDB in our PHP applications, using the excellent PHP HTTP library Guzzle. Guzzle is a modern, PSR-7 compliant object-oriented PHP library that handles all aspects of HTTP in a correct and — importantly, a scalable — way. So it’s a great way to add any HTTP-interfaced services into your application (PHP 5.5 and later, does support PHP 7).

She then starts off with the installation of Guzzle via Composer and some sample code to make the initial connection to the CouchDB server (either local or remote). With the connection up and working and a "welcome" banner returned, she shows some simple operations like:

  • getting a list of all databases
  • creating a new database
  • inserting and selecting data
  • updating and deleting data

Code is provided for each of these and, thankfully, Guzzle makes it a pretty simple process and handles most of the heavy lifting on the HTTP requests for you.

tagged: couchdb guzzle introduction database http install connect crud

Link: https://developer.ibm.com/clouddataservices/2016/07/27/get-started-with-couchdb-php-guzzle/

SitePoint PHP Blog:
Hacking the Fitbit – Emulating a Pager for Twitter DMs!
Jun 17, 2016 @ 15:27:57

The SitePoint PHP blog has a tutorial they've posted from Christopher Pitt showing you how to hack your Fitbit into a pager for Twitter DMs. This essentially turns your Fitbit into a notification system for when someone on Twitter sends you a direct message. It's not overly useful (as you can't send a message) but it is an interesting integration.

I’ve been trying to wake up earlier in the morning. The trouble is that alarms wake everybody up, not just me. To get around this problem, I recently bought the cheapest Fitbit I could find, having learned that they have a neat silent alarm.

The truth is, if I had the cash I would rather have bought an Apple watch. When I got the Fitbit, my programmer brain immediately jumped to the question; “How can I hack this thing?” I ended up learning a bit about Fitbit, OAuth and the Twitter API. I also learned that sometimes it’s better just to get an Apple watch…

His application uses Lumen as the framework and makes connections to both the Twitter and Fitbit JSON APIs. He defines a few routes for the OAuth handling (with callbacks) and a simple view with the "Connect To" links. He shows the creation of applications on both the Twitter and Fitbit side and how to define their keys in your configuration. He sets up the Socialite providers for both connections and a bit of caching to prevent the need for a full pull. He then uses the Fitbit API to set "silent alarms" on your device that are timed to go off immediately when the app detects a new DM on the Twitter stream.

tagged: tutorial fitbit twitter api connect application alarm directmessage

Link: https://www.sitepoint.com/hacking-the-fitbit-emulating-a-pager-for-twitter-dms/

PHPBuilder.com:
How to Connect Your PHP Application to Google Cloud Storage
Jul 15, 2015 @ 17:47:27

On PHPBuilder.com they've posted a tutorial showing you how to connect your PHP applications to Google Cloud Storage with the help of a Google App Engine instance and their own SDK.

In this article, I'll show you how to take advantage of Google's Platform as a Service (PaaS) in order to create a scalable, highly available and secure PHP web application. Note: The instructions are for Mac OSX, but may work for Linux too. Slight modifications may be needed for Windows.

They show you how to use the SDK and a bit of configuration to create a simple script that connects to the Google Cloud Storage (via a simple file_get_contents call), fetches a list of images and pulls out a random "meme" image to show from the list. They've also posted a live demo if you'd like to see the result.

tagged: google appengine cloudstorage tutorial deploy connect sdk

Link: http://www.phpbuilder.com/articles/databases/how-to-connect-your-php-application-to-google-cloud-storage.html

Phillip Shipley:
Creating a PHP Nexmo API Client using Guzzle Web Service Client – Part 2
Apr 09, 2015 @ 16:58:38

Phillip Shipley has posted the second part of his series (first part is here) about creating a PHP client for the Nexmo API with Guzzle, the popular PHP HTTP client.

In Part 1 of this series we laid a foundation for consuming the Nexmo SMS API and covered a few ways to interact with it. In this part we’ll create the actual Guzzle Web Service Client to interact with it to demonstrate how simple it can be.

He starts by getting Guzzle installed via Composer including a few extra components: guzzle-services, retry-subscriber and log-subscriber. He defines the structure (code) for the message to send to the Nexmo service. Next up is the creation of the actual client that takes in configuration settings and extracts the HTTP location and applies the provided credentials to the connection. Finally he makes a simple SMS client that extends this base client and puts it to use with a simple message defined in an array (to, from and text contents). The client then reports back the results in a simple nested array with response information from the Nexmo API.

tagged: nexmo client guzzle webservice api part2 series connect send

Link: http://www.phillipshipley.com/2015/04/creating-a-php-nexmo-api-client-using-guzzle-web-service-client-part-2/

Brian Moon:
Using socket_connect with a timeout
Mar 12, 2015 @ 14:38:00

In a new post to his site Brian Moon has shared a problem he had with sockets and timeouts and having them perform the same way every time. He walks through the symptoms he was seeing and provides his own solution in the end.

So, it seems that when you try and connect to an IP that is routable on the network, but not answering, the TCP stack has some built in timeouts that are not obvious. This differs from trying to connect to an IP address that is up, but not listening on a given port. [...] After a lot of messing around, a coworker pointed out that in production, the failures were happening for an IP that was routable on the network, but that had no host listening on the IP.

After some testing, Brian figured out that his problem was using localhost for testing and not an actual non-host server. He made the switch and figured out how to set the timeouts low and work with error state checking to make things more stable. He explains a bit more about how the code in his solution works. You can find his solution in this gist on GitHub.

tagged: socket connect timeout issue stable consistent failure localhost

Link: http://brian.moonspot.net/socket-connect-timeout

NetTuts.com:
Building With the Twitter API: Using Real-Time Streams
Nov 18, 2014 @ 17:28:14

NetTuts.com finishes off their series covering how to connect your application to Twitter and pull data. In this latest tutorial they show the use of the real-time streams Twitter offers to those needing the most up-to-date and immediate access to tweets via a command-line tool. This tutorial makes use of the Yii PHP framework for it's execution.

While the Twitter REST API is suitable for many applications, if you want immediate updates and access to a broader array of notifications, the Twitter Streaming API is essential. For example, only the streaming API will tell you when another user favorites one of your tweets. Using the Streaming API requires a persistent, keep-alive connection between your web server and Twitter. This type of implementation may be unfamiliar to many PHP developers. As soon as tweets come in, Twitter notifies your server in real time, allowing you to store them into your database without the delay of polling the REST API. Use of the Streaming API is also not subject to Twitter's API rate limits.

They start with a brief description of the Streams functionality and provide a graphic showing the overview of the data flow when you put them to use. They make use of the phirehose library to make the connection (making it almost a two-step method: connect & consume). They walk you through the creation of a Yii command to create the command and set it up for execution. They show you how to integrate it into a larger Yii application, create a migration to store the data and execute the resulting code as a long running command.

tagged: realtime streams twitter tutorial series phirehose connect consume

Link: http://code.tutsplus.com/tutorials/building-with-the-twitter-api-using-real-time-streams--cms-22194

PHPMaster.com:
An Introduction to Redis in PHP using Predis
May 03, 2012 @ 14:35:21

On PHPMaster.com today there's a new tutorial by Daniel Gafitescu showing you how to work with Redis (a key-value store) via PHP with the help of the Predis library.

There is a lot of argument whether Redis or Memcache is better, though as the benchmarks show they perform pretty much on par with each other for basic operations. Redis has more features than Memcache has, such as in-memory and disk persistence, atomic commands and transactions, and not logging every change to disk but rather server-side data structures instead. In this article we'll take a look at some of the basic but powerful commands that Redis has to offer using the Predis library.

He helps you get a local redis server up and running and includes a link to the repository for the latest version of the Predis library. Some sample code is provided showing how to connect to the server, push data into a key/value combination, get the value back out, increment it and check to see if it exists. He also talks about some of the available data types Redis provides and a few other more complex operations you can perform on things other than strings.

tagged: predis redis tutorial library connect server

Link:

SpyreStudios.com:
Connecting with API Data from Instagr.am using PHP
Feb 17, 2012 @ 16:02:43

On SpyreStudios.com there's a post showing you how to connect to the Instagr.am API and pull data back with a bit of simple PHP.

The process of connecting into API data via OAuth is tricky. Some of the more notable social networks which have adopted this technology include Foursquare, Twitter, and Facebook. But Instagram is a very popular mobile app which has grown tremendously fast. Their recent API v1.0 release has some really neat features where you can pull popular photos, recent users, follower lists, and a whole bunch more.

He points to the Instagr.am PHP API scripts that the service already provides and shows how to set up an application on your Instagr.am account. This application then has OAuth keys you can use to connect to the service (via the PHP API scripts) and pull back basic user information - profile picture, number of photos, followers, etc. There's also a live demo you can test out.

tagged: instagram api connect oauth application tutorial

Link:


Trending Topics: