News Feed
Sections




News Archive
feed this:

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

SitePoint PHP Blog:
Popular Users per Language and Region with Silex and Github
June 18, 2015 @ 11:53:49

The SitePoint PHP blog has a new tutorial posted showing you how to use the data the GitHub API provides to find popular users, per language, in an area. His sample example is a simple Silex framework based application and uses the KNPLabs GitHub library to interface with the API.

The data you can get through the GitHub API V3 is mostly what you can see on the GitHub web interface, except you can use the data in your application to come to interesting conclusions. That is what we are going to do in this article. [...] Now, what if there was a web service in which we could specify a location and a language (e.g. PHP) and get a sorted list of contributors to open-source? [...] In our web service, we will have one endpoint (i.e. action, URL) that shows the most popular ten creators. The most popular creators are the people in a location who have the largest number of stargazers. For this, we will retrieve each person's repositories and add up the number of times each one has been starred.

He steps you through getting a Homestead Improved VM up and running (via Vagrant) and a basic Silex application up and running inside. He then pulls in the KNPLabs GitHub library via Composer and sets up a new client in the default route (and grabs the public user data for a user). He then shows how to change it up and use the Search API and some special queries to locate users by a given location. He adds another class, a "StarGazerCalculator", that's given the users returned, filters out the forks in the list and calculates the total "stargazer" count for the user. He does the same with the "top creators" list and sets it up as a service provider, fetches the data and returns the results as a JSON document.

0 comments voice your opinion now!
popular user language region github api silex tutorial

Link: http://www.sitepoint.com/popular-users-per-language-region-silex-github/

SitePoint PHP Blog:
Record Retrieval and Pagination in Bolt CMS
June 02, 2015 @ 12:29:59

The SitePoint PHP blog has a new tutorial posted showing you how to set up pagination in the results provided by the Bolt CMS that includes handling to grab content from the database and display the results.

Bolt is a lightweight CMS built on Silex with Symfony components that's fast, easy, and fun to develop with. My recent affinity for Bolt has turned it into my CMS of choice as I make a conscious effort to choose wisely and step away from bloated frameworks. Previously, I gave a very detailed insight into what it's like developing with Bolt. Today, we're going to break down a very popular task into steps in order to accomplish it with ease.

He starts with an installation of the Homestead Improved virtual machine and checks out a new copy of Bolt. He sets up a basic Bootstrap-based theme, including header and footer partial views. He then shows how to create "contenttypes" and fetch the current content records. He updates the Twig template to show the results and integrates the simple pagination. He then creates the single page version to view the content and "previous" and "next" links to accompany it.

0 comments voice your opinion now!
bolt cms tutorial pagination content type management silex

Link: http://www.sitepoint.com/record-retrieval-pagination-bolt-cms/

SitePoint PHP Blog:
Pagination with jQuery, AJAX and PHP
May 28, 2015 @ 09:46:57

The SitePoint PHP blog has a new tutorial posted showing you how to set up pagination with jQuery and PHP using a simple Silex-based application.

n this article, we're going to explain how easy it is to paginate your data set using PHP and AJAX via jQuery. We're also going to use the Silex framework for simplicity.

The data he's going to paginate through is a list of "people" data with ID, name and age values. He starts by helping you get Silex installed and a new project created. With that in place, he shows how to inject the database connection (PDO) into the application and set up the simple route to output the "people" data back to the waiting Javascript. The route includes a page number value that's used in the LIMIT statement to segment the results into pages. He also includes another route that returns a total count of people records so the pagination knows when to end. With the backend in place, he then moves to the frontend, showing the complete code to get the page records and populate them into the page (via a list).

0 comments voice your opinion now!
pagination tutorial ajax jquery silex people data

Link: http://www.sitepoint.com/pagination-jquery-ajax-php/

Gonzalo Ayuso:
Building TCP server daemond with PHP and Rachet
April 13, 2015 @ 10:18:41

Gonzalo Ayuso has a new post to his site today showing how to create a TCP server daemon with PHP with help from the Ratchet toolset. Ratchet is a library that makes it easier to work with WebSockets directly from PHP.

In my daily work I normally play a lot with TCP servers, clients and things like that. I like to use Linux's xinet.d daemon to handle the TCP ports. I've also written something about it. This approach works fine. The problem appears when we call intensively our xinet.d server. It creates one PHP instance per request. It isn't a problem with one request in, for example, 3 seconds, but if we need to handle 10 requests per second our server load will grow. The solution: a dedicated server.

In a setup similar to how Silex registers callbacks, he's created a PHP-based server that listens on whatever ports are defined for incoming connections and processes the data accordingly. He includes several code samples that show it in use, both in simple request handling and more complex configurations based off of a YAML file definition. He ends the post with a method he uses to "emulate" threading in his processing with the help of a Silex app and HTTP requests to hand off the processed and remove the blocking problem PHP introduces.

0 comments voice your opinion now!
tcp server daemon ratchet websocket silex tutorial

Link: http://gonzalo123.com/2015/04/13/building-tcp-server-daemon-with-php-and-rachet/

SitePoint PHP Blog:
Integrate Elasticsearch with Silex
April 13, 2015 @ 08:38:55

The SitePoint PHP blog has continued their look at integrating Elasticsearch into a simple Silex-based PHP application. In this latest part of the series (part two) they move away from the full Drupal example in part one and go a bit more simple and create a basic site to show a node's detail (content and title).

In the previous article I started exploring the integration between Drupal 7 and the Elasticsearch engine. The goal was to see how we can combine these open source technologies to achieve a high performance application that uses the best of both worlds. [...] We'll now create a small Silex application that reads data straight from Elasticsearch and returns it to the user.

Using Silex and the same Elasticsearch PHP SDK they create this simple site. The tutorial walks you through the installation of both tools, the configuration of the Elasticsearch client and creating the controllers to respond to the view requests. They also show how to use the Twig templating engine to render the results as a simple page containing the node title, any images attached to it and the body content. The tutorial ends with a brief mention of how this same data could also be rendered as JSON output with a different view handler.

0 comments voice your opinion now!
silex tutorial elasticsearch simple twig template json node drupal

Link: http://www.sitepoint.com/integrate-elasticsearch-silex/

SitePoint PHP Blog:
Introduction to Silex - A Symfony Micro-framework
February 20, 2015 @ 12:31:40

The SitePoint PHP blog has a tutorial posted today introducing you to one of the more popular PHP microframeworks out there, Silex. This new article jumps right in and shows you how to use it.

Silex is a PHP micro-framework based on Symfony components and inspired by the Sinatra Ruby framework. In this article, we are going to get started with the framework and see the how it fits our needs.

He walks you through the installation of Silex (and Twig) through Composer and the creation of the basic folder structure to build the first app. He then gets into talking about how routes are handled, parameters and linking controllers to routes. He also introduces the use of providers and shows how to implement the one for Twig to use in templating the output of the application.

0 comments voice your opinion now!
silex microframework introduction tutorial symfony twig

Link: http://www.sitepoint.com/introduction-silex-symfony-micro-framework/

SitePoint PHP Blog:
3 Ways to Implement Embeddable Custom Badges
December 29, 2014 @ 09:12:38

The SitePoint PHP blog has a recent tutorial showing you how you can use one of three different ways to embed badges into your site. These "badges" are a common practice among sites allowing other sites/applications to embed small statistics such as number of Tweets or Likes about a page.

One great way of organically promoting your application is to provide "badges"; snippets of content that people can embed on their own websites. [...] This can contain up-to-the-minute information from your application about a user, piece of content or another object, dynamically generated and inserted into other websites. In this article I'm going to take a look at some of the ways you can implement this.

He walks you through the creation of a simple application based on Silex, using Twig for template rendering and the WideImage library for creating the images. His datastore, a static array, lists an image, rank and number of "trophies" for each user of the system. He creates a main page showing all of the badges at once, making use of an "iframe" to contain the dynamically created image. He shows how to use the WideImage library to pull in the background, avatar and trophy images, merge them together and add a bit of text with the username and level ranking. Finally he includes the Javascript needed so the remote site can just use a "script" tag to pull in the rendered image and place it on their page.

0 comments voice your opinion now!
tutorial badge embed javascript iframe silex twig wideimage

Link: http://www.sitepoint.com/3-ways-implement-embeddable-custom-badges/

Imagine Easy Solutions Blog:
Testing Logging in Silex
November 12, 2014 @ 11:34:50

On the Imagine Easy Solutions blog Yitzchak Schaffer talks some about logging in Silex by making use of a MonologServiceProvider. You can find the end result of his setup in this GitHub repository.

Silex is a PHP microframework from the same family as Symfony. My shop, Imagine Easy Solutions, uses Silex for some of our most important applications. Modular setup is at the core of Silex's game, by means of Service Providers. The MonologServiceProvider makes it easy to add highly configurable logging to your application. But how to test your logging? It turns out that this Service Provider includes a DebugHandler which you can use to make log entries available in array form.

He walks you through the integration of the service provider via a "debug handler" and configuring it in the setup method. He also includes an "assertLogEntry" method to evaluate the current logs and check to ensure an entry was made. Finally, he puts it to use via a "notOk" method.

0 comments voice your opinion now!
test logging silex serviceprovider monolog tutorial

Link: http://dev.imagineeasy.com/post/102394035784/testing-logging-in-silex

Gonzalo Ayuso:
Token based authentication with Silex and AngularJS
June 09, 2014 @ 10:33:37

Gonzalo Ayuso has posted a tutorial showing how to use token-based authentication with a Silex-based application through a request from AngularJS.

According to my last post today we're going to create a AngularJS application that uses the Silex Backend that we create previously. The idea of this application is to use it within a Phonegap/Cordova application running in a mobile device.

He includes the code (and markup) you'll need to make the request work. Basically, it uses a standard HTTP service from inside AngularJS to fetch the token and store it in the client's localstorage. The rest of the code does the checking to see if the user is logged in (the token exists) or if it needs to sow the login form. The "logged in" route also displays an alert to the user with the info (pulled from the API) for their user. The full code for the example can be found over on GitHub.

0 comments voice your opinion now!
token authentication silex angularjs tutorial login localstorage

Link: http://gonzalo123.com/2014/06/09/token-based-authentication-with-silex-and-angularjs/

Gonzalo Ayuso:
Token based authentication with Silex Applications
May 06, 2014 @ 10:56:32

Gonzalo Ayuso has put together a new post for his site showing how to do token-based authentication with Silex and the help of a few additional Symfony components.

What happens if we want to use a security layer [in a Silex application]? We can use sessions. Sessions are the "standard" way to perform authentication in web applications, but when our application is a PhoneGap/Cordova application that uses a Silex server as API server, sessions aren't the best way. The best way now is a token based authentication. The idea is simple. First we need a valid token. Our API server will give us a valid token if we send valid credentials in a login form. Then we need to send the token with each request (the same way than we send the session cookie with each request).

He includes all the code you'll need to follow along. His example shows a basic Silex application that fetches the token from the URL and uses middleware to handle the validation. There's a bit of CORS mixed in as well to make the cross-domain requests from the applications possible. He creates a service provider (for logins) and controller provider to handle each type of request.

0 comments voice your opinion now!
token authentication silex application tutorial

Link: http://gonzalo123.com/2014/05/05/token-based-authentication-with-silex-applications/


Community Events

Don't see your event here?
Let us know!


community symfony php7 api programming opinion application part2 podcast series yii2 laravel project interview example list introduction framework language composer

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework