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

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/

Stephan Hochdörfer:
Silex running on HHVM
April 09, 2014 @ 09:14:12

Stephan Hochdörfer has a quick new post to his site today showing how he was able to setup a Silex-based application to run on the HHVM (HipHopVM) from Facebook.

First of all I assume you already got HHVM running with nginx. If this is not the case feel free to follow these steps to get everything up and running. To install Silex we will use Composer, so let`s install all the needed requirements and Composer itself.

He includes all the commands you'll need to get the Composer dependencies installed (curl, git, unzip) and to pull it down and move it to the right location post-install. He adds a line to his ".bashrc" to enable it for HHVM and creates the sample "composer.json" for the Silex install. Finally, he includes the updates to make to the nginx configuration to handle the needed redirects to the Silex front controller.

0 comments voice your opinion now!
hhvm silex install configure nginx tutorial framework

Link: http://blog.bitexpert.de/blog/silex-running-on-hhvm/

Gonzalo Ayuso:
Integrating WebSockets with PHP applications. Silex and socket.io playing together.
February 04, 2014 @ 09:37:25

Gonzalo Ayuso has a new post today showing you how you can integrate websockets with a PHP application using a combination of Silex and socket.io, a javascript library specifically made to work with them.

WebSockets are great. We can start a persistent connection from our browser to our server and use this connection to send real time notifications to our users. Normally when we integrate WebSockets with an existing Web application, we need to face with one slight problem. Our Web application runs on a Web server (imagine, for example one Silex application). We can use a login form and ensure all requests are authorized (using a security layer). This problem is solved years ago. We can use Basic HTTP authentification, Digtest authentification, a session based athentification, token based authentificatio, OAuth, The problem arrives when we add WebSocket server.

He mentions another solution - sharing an authentication mechanism between the frontend and backaned - but suggests something simpler using the bi-directional nature of websockets. To illustrate, he makes a simple Silex application and creates a basic template that makes the websocket request back to the localhost. He includes the simple code to make the socket.io server (node.js) and an example of using Express to handle the request and define the URL to call on the Silex application. He's also created a screencast showing the full process, start to finish.

0 comments voice your opinion now!
websockets socketio silex websockets tutorial authentication security

Link: http://gonzalo123.com/2013/12/24/integrating-websockets-with-php-applications-silex-and-socket-io-playing-together

David Makin:
Creating a simple REST application with Silex part 2
January 24, 2014 @ 12:17:35

David Makin has posted the second part of his series looking at creating a simple REST API with the help of Silex. You can find part one here to get caught up.

In part 1 you installed Silex and setup 2 routes, / and /{stockcode}. Now lets expand upon those by adding a POST and a DELETE route. The 2 routes we created use GET but to make your application truly useful you will want to use at least 1 more type and that is POST.

He starts by adding a new POST route to handle the creation of a new "toy", complete with a correct response of a 200 code (HTTP for "created"). He follows this with a DELETE example, showing how to return a 204 if the delete works or a server error if something goes wrong. He also includes a curl call to test out the endpoints. In the upcoming third part David will look at breaking up the code a bit and putting it into separate files.

0 comments voice your opinion now!
silex rest application tutorial introduction delete created

Link: http://sleep-er.co.uk/blog/2014/Creating-a-simple-REST-application-with-Silex-part2/

David Makin:
Creating a simple REST application with Silex
December 27, 2013 @ 10:36:48

David Makin has put together a new post to his site showing you how to make a simple REST web service with Silex, the PHP microframework from the Symfony project.

So you have come to the conclusion that, rather than having the code to update customer details and that little fix to convert the date from GMT to UTC should happen in once place rather than being copied into several pieces of code, a REST service is the answer. Perhaps you just think you should know how to create a REST service. Either way this post is for you. In this post we will start off with a blank directory and go through installing Silex and getting it to serve a couple of simple routes.

He helps you get Silex installed via Composer and gets you started with a simple root and "stock code" route. He uses these to explain a bit about the framework's route handling and includes URLs to call that will execute them.

0 comments voice your opinion now!
silex microframework introduction beginner tutorial

Link: http://sleep-er.co.uk/blog/2013/Creating-a-simple-REST-application-with-Silex/

Aura Blog:
Which is Lighter, Silex or Aura.Web_Project?
December 26, 2013 @ 09:40:01

In a recent post the Aura PHP blog compares the "lightness" of two different micro-framework-oriented packages - Silex and Aura.Web_Project (of the Aura framework project.

Too many people, including the Silex article author, use absolute terms like "light" and "heavy" and "bloated", instead of relative terms like "lighter" and "heavier" and "more bloated" and "less bloated", to describe software. Any time someone uses an absolute term like that, you need to ask: "Compared to what?" [...] don't know if the measurements in that article are valid or useful for defining "what makes a microframework" but they do provide a basis for comparison. I understand that some people think "measuring (size|lines-of-code|number-of-classes) is stupid and it doesn't matter!" Maybe it is, maybe it's not. [...] So, let's go with that article and use its approach to make a comparison between Silex and Aura.Web_Project to see if my earlier claim, using the terms and measurements outlined by the Silex post author, is accurate.

The rest of the post outlines the steps that were taken to perform the measurements, the tools used check things like memory usage and the results. They compare things like:

  • Total Package Dependencies
  • Total Disk Usage
  • Total Class Count
  • "Actual Usage" Class Count
  • "Actual Usage" Non-Comment Lines Of PHP Code
0 comments voice your opinion now!
silex aura framework webproject compare lighter

Link: http://auraphp.com/blog/2013/12/23/lightness-silex-vs-web-project/

Gonzalo Ayuso:
How to run a Web Server from a PHP application
November 11, 2013 @ 11:53:06

Gonzalo Ayuso has put together a post showing how (by implementing the Reactor design pattern) he created a simple web server inside a PHP application. It combines a few Symfony2 components and the React library to build a simple server in a bit more programatic way.

Normally we deploy our PHP applications in a webserver (such as apache, nginx, ). I used to have one apache webserver in my personal computer to play with my applications, but from time to now I prefer to use PHP's built-in webserver for my experiments. It's really simple. [...] With PHP we cannot do it. Sure? That assertion isn't really true. We can do it. I've just create one small library to do it in two different ways. First running the built-in web server and also running one React web server.

The idea is that all that would be needed is a stand-alone PHP script that could be run anywhere and start up its own web server, no other software required. He includes a simplified version of the example, showing how to make servers with both React and PHP's own server. He also includes an example of a basic Silex application that uses it as well as some benchmarks (with Apache ab) for each of the implementations and their request/response times on average for simple and Silex requests.

0 comments voice your opinion now!
builtin webserver server example react silex

Link: http://gonzalo123.com/2013/11/11/how-to-run-a-web-server-from-a-php-application/

Chris Jones:
Tracing Silex from PHP to the OS with DTrace
November 06, 2013 @ 12:31:23

Continuing on with his look at using DTrace in with PHP, Chris Jones has a new post in the series showing how to add traces to Silex-based applications, including sample output.

In this blog post I show the full stack tracing of Brendan Gregg's php_syscolors.d script in the DTrace Toolkit. The Toolkit contains a dozen very useful PHP DTrace scripts and many more scripts for other languages and the OS. For this example, I'll trace the PHP micro framework Silex, which was the topic of the second of two talks by Dustin Whittle at a recent SF PHP Meetup. His slides are at Silex: From Micro to Full Stack.

He includes a brief guide to getting the DTrace support up and running based on instructions in a previous post based on some pre-build Oracle linux packages. He links to the latest DTrace Toolkit and the downloads page to get the latest version of Silex. He sets up a super-basic Silex application (one route, "hello") and shows how to run the DTrace against it. His sample output shows both the PHP files being called and the functions/methods called inside them resulting in an output over a thousand lines long.

0 comments voice your opinion now!
silex dtrace trace execution oracle package toolkit tutorial

Link: https://blogs.oracle.com/opal/entry/tracing_silex_from_php_to

Gonzalo Ayuso:
Playing with event dispatcher and Silex. Sending logs to a remote server.
October 22, 2013 @ 09:44:57

Gonzalo Ayuso as a new post today showing the results of some of his testing with the event dispatcher and Silex to send logs to a remote server.

Today I continue playing with event dispatcher and Silex. Now I want to send a detailed log of our Kernel events to a remote server. We can do it something similar with Monolog, but I want to implement one working example hacking a little bit the event dispatcher. Basically we're going to create one Logger class (implementing PSR-3 of course).

He includes the sample code defining a "Logger" class that takes whatever message sent to it and pushes it into a given socket resource. He also creates a provider for the logger to implement it in the example and registers it with the event dispatcher. He hooks it into the request, get controller, terminate and exception events. On the other side he uses React to make a basic server to listen on port 4000 for the incoming log data.

0 comments voice your opinion now!
silex event dispatcher remote server log logger psr3

Link: http://gonzalo123.com/2013/10/21/playing-with-event-dispatcher-and-silex-sending-logs-to-a-remote-server/


Community Events





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


interview application release community laravel configure install library introduction list threedevsandamaybe series language bugfix wordpress developer code podcast unittest api

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