Niezalogowany [ logowanie ]
Subskrybuj kanał ATOM Kanał ATOM    Subskrybuj kanał ATOM dla tagu symfony2 Kanał ATOM (tag: symfony2)

Autor wpisu: Wojciech Sznapka, dodany: 16.08.2012 10:45, tagi: php, symfony, symfony2

During upcoming edition of PHPCon 2012 in Kielce I’ll give a talk “Symfony2 w chmurze” (Symfony2 in the cloud). I’ll describe advantages of cloud infrastructure purposed for web applications, some use cases of cloud deployments and things which developers need to keep in mind, to get Symfony2 application work properly in such environment. More informations [...]

Autor wpisu: Kamil Adryjanek, dodany: 06.07.2012 19:46, tagi: symfony2, eclipse

Today I want to share with you another great plugin that is perfect for Symfony2 developers or anyone who wants to have Doctrine, Twig or Yaml support using Eclipse IDE.

From symfony.dubture.com:

What’s this?

An Eclipse plugin for Symfony and the Symfony components . Features include:

– Codeassist for Symfony specific elements, like services, routes, template paths, entities, translations and twig blocks. – Navigation: Hyperlinking of routes, templates, twig blocks/functions/filters and services – Annotation support – Twig support Twig

Twig is a templating language for PHP. Symfony has built in support for Twig, and so does the Symfony Eclipse Plugin. Doctrine

Doctrine is a

viagra online

set of PHP libraries primarily focused on providing persistence services and related functionality. It comes bundled with the Symfony Standard-Edition as the default ORM. The Symfony Eclipse Plugin also provides Doctrine support.

Yaml

Yaml is a data serialization standard which is supported by Symfony. If you’re using yaml, you can use the optional Yedit feature. The plugin is maintained by oyse. Too keep things simple, the Symfony Plugin updatesite makes the Yedit feature available too.

Czytaj dalej tutaj (rozwija treść wpisu)
Czytaj dalej na blogu autora...

Autor wpisu: Wojciech Sznapka, dodany: 20.04.2012 19:49, tagi: symfony2, php

When you have plenty of Symfony2 applications and you need to deploy them from time to time, you are probably sick of thinking about every activity you need to do for every deploy. Often people use some build scripts, which are hard to maintain and tends to be unreadable. I wanted to automate it as [...]

Autor wpisu: Tomasz Kowalczyk, dodany: 11.04.2012 22:28, tagi: symfony2, php, framework, design

W ostatnim tygodniu znowu trochę „przysnąłem” z wpisami, ale wytłumaczenie jest proste: już w środku tygodnia bez zbędnych ceregieli pojechałem do domu na święta i przez ten czas komputer (poza totalnie nie wymagającymi myślenia czynnościami typu klikanie na społecznościówkach) był … #LINK#

Autor wpisu: Tomasz Kowalczyk, dodany: 26.03.2012 22:09, tagi: symfony2, php

Zgoda, minęło trochę czasu od ostatniego wpisu, ale wraz z nowym szablonem czas powrócić do starych dobrych czasów, kiedy to ukazywało się kilka wpisów tygodniowo. O wszystkich zmianach skrobnę nieco w innym wpisie, a tymczasem zapraszam Was do lektury kolejnego … #LINK#

Autor wpisu: Wojciech Sznapka, dodany: 18.01.2012 21:05, tagi: php, symfony2

How many times were you curious which one of, modern web frameworks is the best? For developers who have their favourite, answer is simple. But there are plenty of questions from begginers or devs who want to learn new technology, wondering which one should take, to stay on the edge. I code in Symfony (PHP) [...]

Autor wpisu: Kamil Adryjanek, dodany: 13.11.2011 02:04, tagi: symfony2, php

In one of my templates i needed a simple way to get controller / action name to generate some dynamic urls. Symfony2 does not offer any Twig helper function to display current controller / action name.

The easiest way that i have found so far is to create Twig extension. In our default bundle we need to create folder Twig/Extension for example Acme/PageBundle/Twig/Extension and place there our Twig extension class:


<?php 
// src/Acme/PageBundle/Twig/Extension/AcmePageExtension.php

namespace Acme\PageBundle\Twig\Extension;

use Symfony\Component\HttpFoundation\Request;


class AcmePageExtension extends \Twig_Extension
{
	protected $request;
	/**
	 *
	 * @var \Twig_Environment
	 */
	protected $environment;
	
	public function __construct(Request $request)
	{
		$this->request = $request;
	}
	
	public function initRuntime(\Twig_Environment $environment)
	{
		$this->environment = $environment;
	}
	
	public function getFunctions()
	{
		return array(
	            'get_controller_name' => new \Twig_Function_Method($this, 'getControllerName'),
	            'get_action_name' => new \Twig_Function_Method($this, 'getActionName'),
		);
	}
	
	/**
	 * Get current controller name
	 */
	public function getControllerName()
	{
		$pattern = "#Controller\\\([a-zA-Z]*)Controller#";
		$matches = array();
		preg_match($pattern, $this->request->get('_controller'), $matches);
		
		return strtolower($matches[1]);
	}
	
	/**
	 * Get current action name 
	 */
	public function getActionName()
	{
		$pattern = "#::([a-zA-Z]*)Action#";
		$matches = array();
		preg_match($pattern, $this->request->get('_controller'), $matches);
	
		return $matches[1];
	}
	
	public function getName()
	{
		return 'acme_page';
	}
}

Next step is to register this service:

// src/Acme/PageBundle/Resources/config/services.yml
    request:
        class:        Symfony\Component\HttpFoundation\Reques
        
    acme.twig.extension:
        class: Acme\PageBundle\Twig\Extension\AcmePageExtension
        arguments:  [@request]
        tags:
            - { name: 'twig.extension' }

and then in twig templates we can simply call:


Controller name: {{ get_controller_name() }}
Action name: {{ get_action_name() }}

Wszystkie wpisy należą do ich twórców. PHP.pl nie ponosi odpowiedzialności za treść wpisów.