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

Nate Turner:
Spinning Up Symfony 2 Development Environments With Vagrant
September 11, 2014 @ 10:57:13

Nate Turner has posted a tutorial to his site sharing a step-by-step method for creating Symfony2 development environments with Vagrant. Vagrant (and Puppet) allow you to create a scriptable setup process that creates a VM with the same settings every time, making it easier to destroy and recreate as needed.

When we use Vagrant to create new virtual development environments we avoid the very real possibility that we could mess up our personal development machines. People have used virtual machines for development for years. [...] Managing installed applications across a teams VMs is a pain. Why not just include a Vagrantfile and a few Puppet manifests instead? Instead of passing around a virtual machine a few gigabytes in size, just include your Vagrant and Puppet in a project's source control. That's it. In future tutorials we will be using the environment we create here to start a new virtual machine running Symfony 2 with the above command.

He walks you through each of the steps, complete with commands and configuration changes to make everything cooperate:

  • Create a Symfony Project with Composer
  • Setting up Vagrant
  • Provisioning with Puppet / Symfony's Requirements
  • Set up a new VirtualHost
  • Set Apache to run as the Vagrant user

He's also posted the complete working script over on his GitHub account.

0 comments voice your opinion now!
development environment symfony2 vagrant puppet tutorial

Link: http://nater1067.github.io/blog/2014/08/25/spinning-up-symfony-2-development-environments-with-vagrant/

Matthias Noback:
Symfony2 Event subsystems
August 25, 2014 @ 10:07:09

In his latest post Mathias Noback takes a look at the Symfony2 event subsystems and the answer to a common problem he's had with it in the past: circular references.

Recently I realized that some of the problems I encountered in the past could have been easily solved by what I'm about to explain in this post. [...] The problem is: having a complicated graph of service definitions and their dependencies, which causes a ServiceCircularReferenceException, saying 'Circular reference detected for service "...", path: "... -> ... -> ...".' Somewhere in the path of services that form the circle you then find the event_dispatcher service.

He shows the wrong way to solve the problem first by injecting a service container into the listener and using services directly from there. In his "entirely different and much better way" he shows a solution that removes dependencies on the main event dispatcher. He shows how to use the event subsystems to avoid this link and gives a more concrete example for domain-related events (with both code and config).

0 comments voice your opinion now!
symfony2 event subsystem listener dispatcher domain

Link: http://php-and-symfony.matthiasnoback.nl/2014/08/symfony2-event-subsystems/

Qandidate.com Blog:
Handling AngularJS POST requests in Symfony
August 14, 2014 @ 11:09:13

The Qandidate.com blog has a quick new post today showing how to handle AngularJS requests with a Symfony framework based backend application. They automate the process of decoding the JSON from the Angular frontend to make it immediately usable to the framework backend.

At Qandidate.com we started using AngularJS last year and I have to say it was love at first sight! Two-way databinding, testability, dependency injection, server communication...awesome! Did I say server communication? We use Symfony 2 (which is awesome too) for our back end API's. Unfortunately AngularJS and Symfony do not speak the same language out-of-the-box. In this post I will show you how we automatically decode JSON requests so we can use it with Symfony's Request object using our symfony-json-request-transformer library (or class actually).

They start with a simple JSON example and the action to handle it (the "postAction") and show the manual json_decode method. Instead of having to do this in each controller action, they define the Request transformer handler. This handler takes the incoming request and allows for modifications to various aspects of the request, including transforming the data. They've posted a full example here that includes the full stack, not just the transformer itself (to show the full flow of the request).

0 comments voice your opinion now!
angularjs request symfony2 transform json request

Link: http://labs.qandidate.com/blog/2014/08/13/handling-angularjs-post-requests-in-symfony/

Piotr Pasich:
CakePHP with Symfony's2 router
August 13, 2014 @ 09:46:27

Piotr Pasich has a new post to his site today showing you how you can use the Symfony2 router with CakePHP, another popular PHP framework. He talks about some of his own experiences using CakePHP and how one module "left a bitter aftertaste" when using it - the route handling.

The second version of CakePhp still has a lot old-fashioned patterns, singletons or lack of tests, but I can live with that. I saw a lot of better or worse frameworks in my life.

He goes through an example of the CakePHP routing including some sample code and a walk-through of the code that actually handles the request. He points out some of the "clean code" violations it makes and gets started integrating the Symfony2 router instead. He extends the CakePHP router and uses this plugin to bridge between the two. He then can call the Symfony router with only slight modifications to things like the "getPath" calls.

0 comments voice your opinion now!
cakephp symfony2 router integrate plugin tutorial

Link: http://piotrpasich.com/cakephp-with-symfonys2-router/

Konrad Podgórski:
A better way to work with assets in Symfony 2
June 25, 2014 @ 13:02:11

Konrad Podgórski has a recent post to his site with his suggestion of a better way to deal with assets in Symfony 2-based applications with the help of some other tools, namely NodeJS, Bower and GruntJS.

I will explain how to work with assets in Symfony framework without having to use Assetic Bundle at all. [...] The process will be really fast and easy to understand even if you never used software listed here. However if you experience any problems do not hesitate to ask for help in comments. Post is quite long because it contain a lot of different configs but don't run away just yet. They are ready to copy & paste.

The setup will download the needed dependencies, merge and minify JS/CSS files, copy font files to the right place and deploy it all to an S3 bucket. He first walks you through the installation of the three tools complete with the commands and configurations to get them all integrated. With those installed and working, he then gets into three "scenarios", the steps in the process to build and deploy the completed version:

  • Download latest jQuery, Bootstrap, Font Awesome with Bower and copy the only necessary files to web/assets/*
  • Download dependencies with Bower, copy necessary files to web/assets/*. Then minify javascript and stylesheet files.
  • Download dependencies with Bower, merge them with your custom css and js files, then minify.

Finally, he includes the steps you'll need to follow to get the whole thing deployed out to S3 (or a CDN). In the next part of the series he'll continue the process and look at things like LESS/SASS, watching for changes in assets and how to use RequireJs.

0 comments voice your opinion now!
assets symfony2 grunt bower nodejs tutorial install configure deploy

Link: http://konradpodgorski.com/blog/2014/06/23/better-way-to-work-with-assets-in-symfony-2/

NetTuts.com:
Working With Databases in Symfony 2
June 19, 2014 @ 12:45:20

In the next part of their Symfony2 screencast series, NetTuts.com has released their introduction to using databases from inside the framework-based application. Other posts in this beginner series (all authored by Andrew Perkins) can be found here.

Today we'll continue working with Symfony 2 where I'll show you how to get started working with databases. I'll be covering setup and config, generating the database, generating your getter/setter methods and table schema, and how to persist data from a form, into a database.

The video walks you through the setup and use of a MySQL database and Doctrine (from the command line) to create the database structure. The use the sample application that's been evolving through a few of the screencasts. In this application, they show how to connect the "Person" entity to a database table through annotations. Included is the code and commands to set up the "Person" entity correctly and how to fetch/save one from a simple controller method.

0 comments voice your opinion now!
symfony2 screencast series database tutorial

Link: http://code.tutsplus.com/tutorials/working-with-databases-in-symfony-2--cms-21461

Matthias Noback:
Symfony2 How to create framework independent controllers?
June 18, 2014 @ 09:15:16

Matthias Noback has a new post to his site today, the first part of a series, looking at making framework-independent controllers for use in a Symfony2 framework-based project.

The general belief is that controllers are the most tightly coupled classes in every application. Most of the time based on the request data, they fetch and/or store persistent data from/in some place, then turn the data into HTML, which serves as the response to the client who initially made the request. [...] In this post I demonstrate that this high level of coupling is definitely not necessary. I will show you how you can decrease coupling a lot by taking some simple steps. We will end with a controller that is reusable in different types of applications, e.g. a Silex application, or even a Drupal application.

In this first part he focuses on a few places where the common practices lead to some unnecessary coupling between the controller and framework:

  • Using the framework helper methods
  • Using dependency injection (manually injecting instead)
  • Making the controller a service instead

The next post in the series will look at the use of annotations and how to refactor them out of the controller to remove yet another coupling point.

0 comments voice your opinion now!
framework independent controller symfony2 tutorial refactor decouple

Link: http://php-and-symfony.matthiasnoback.nl/2014/06/how-to-create-framework-independent-controllers/

NetTuts.com:
Form Validation in Symfony 2
June 12, 2014 @ 10:15:29

NetTuts.com has continued their screencast series introducing the Symfony 2 framework and some of the basic concepts around things like routing, templating and controllers. In this latest post they build on a previous post and show how to use the form validation already built into the framework in some custom forms.

Today we're going to continue where we left off last time, where we learned how to build reusable forms in Symfony 2. In this video, we'll learn how to validate the data that has been submitted to our form to ensure it is in the correct format, meets our data's requirements and then process the form submission accordingly. [Once finished we'll] now have a working form, which validates our data and displays the validation error messages back to the user.

The screencast (also viewable on YouTube) is only about ten minutes long and shows you how to validate a form with an email address and that the other field is "not blank". He does base it off of the form created in the previous tutorial so if you haven't done that one yet, it's better to start there and come back.

0 comments voice your opinion now!
form validation screencast symfony2 tutorial series

Link: http://code.tutsplus.com/tutorials/form-validation-in-symfony-2--cms-21397

SitePoint PHP Blog:
Building and Processing Forms in Symfony 2
June 06, 2014 @ 13:45:07

The SitePoint PHP blog has a new tutorial posted from author Daniel Sipos about form handling in Symfony2. More specifically, about creating them and handling the results from their submission. This is an introduction to the topic and gets into two examples, one focusing on a view implementation and the other using the form builder.

In this tutorial we will look at two examples of using forms in Symfony 2. In the the first, we will place form elements straight in the View file and then handle the form processing manually in the controller. In the second, we'll use the Symfony form system to declare forms in an object oriented way and have Symfony process and persist the values. We will be working on a simple installation of the Symfony framework.As you may know, it comes with a default bundle called AcmeDemoBundle and we will use that to illustrate working with forms.

In the first example he looks at "non-entity forms" and shows how to create the form from normal HTML elements in the view. The form is just a simple input field and a submit button. He includes the code you'll need to process the form submission too. In the second example he includes an example of how to create the same setup but using the Form Builder instead. It's also links it to a data object, making it simpler to save the submission results.

0 comments voice your opinion now!
symfony2 form processing view builder entity manager tutorial

Link: http://www.sitepoint.com/building-processing-forms-in-symfony-2

SitePoint PHP Blog:
Autogenerate CRUD Apps with Phreeze
May 30, 2014 @ 12:45:02

On the SitePoint PHP blog today Taylor Ren has shared a tutorial about using Phreeze to easily create CRUD applications for a MySQL backend. Phreeze is made up of three parts: an MVC handler, an ORM for database interaction and the "Phreeze Builder" to generate the application code.

Back in the times of Symfony 1.x, the framework had a powerful backend module to help the developers and site administrators create a good enough app and provide necessary CRUD features to manage the database (and save us from using PHPMyAdmin). [...] In this article, we will take a look at Phreeze, a simple and easy to use PHP framework that can help us generate a MySQL CRUD backend app. I will use my book collection test site as the underlying database. Please refer to my Data Fixtures in Symfony2 article for more details on the database structure.

He walks you through the installation of Phreeze (downloaded from GitHub) and what the first page should look like when pulled up in a browser. The wizard helps with the database setup and lets you pick the tables to generate models for as well as a few other application options. He shows how to integrate this generated code with a simple Symfony2-based application and easily allow for working with the database contents. He modifies the Symfony2 code to handle some additional options to pass into the generated code and talks some about the API interface Phreeze generates automatically.

0 comments voice your opinion now!
phreeze generate code application symfony2 integration

Link: http://www.sitepoint.com/autogenerate-crud-apps-phreeze/


Community Events





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


library language tips zendserver release interview list deployment podcast laravel introduction community framework bugfix symfony conference developer api voicesoftheelephpant series

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