PHP Frameworks and Symfony

Post on 15-Jan-2015

719 views 5 download

description

An overview of Symfony. Symfony is a PHP framework for web projects. Speed up the creation and maintenance of your PHP web applications. Replace the repetitive coding tasks by power, control and pleasure.

Transcript of PHP Frameworks and Symfony

Symfony

What is Symfony?➔a web application framework for PHP5 projects.

- Opensource, MIT license

- OOP

- MVC

➔by Fabien Potencier, SensioLabs (France)

- 2005. first version was released

- 2007. symfony 1.0

- 2011. Symfony2

- ATM Symfony 2.3.4 (LTS)

Framework➔A software framework is a

universal, reusable software platform to develop applications, products and solutions.

➔Why?➔ Avoid “reinventing the

wheel”➔ Use proven, tested code➔ Maintainability

➔When?➔ general vs. specific needs

➔ packaged software➔ CMS (content

management system)➔ framework 

MVC (Model–view–controller)

➔The model consists of application data, business rules, logic, and functions.

➔A view can be any output representation of data, such as a chart or a diagram.

➔The controller mediates input, converting it to commands for the model or view.

View

ModelController

some Symfony features...

Support for multiple platforms

Scaffolding - for CRUD templates

multilingualism and I18N support

Database Engine Independent

cache management

Reasons to use Symfony1. Reputation

2. Permanence

3. References

4. Innovation

5. Resources

6. Interoperability

Installation: www.symfony.com

Download, Extract, Start

What is inside?

Console Commands

Welcome!

Creating Pages in Symfony2

1. Create a route2. Create a controller

Routing (smart URLs )

✗http://cusearch09.com/user/upload/imageThumb.php?id=5&width=320

✔http://cusearch09.com/user/image/5/320

Controller

class HelloController

{

    public function indexAction($name)

    {

        return new Response('<html><body>Hello '.$name.'!</body></html>');

    }

    public function successAction()

    {

        return new Response('<html><body>Process succeeded!</body></html>');

    }

}

Modelclass Product{    /** @ORM\Id    @ORM\Column(type="integer") */    protected $id;    /** @ORM\Column(type="string", length=100) */    protected $name;    /** @ORM\Column(type="decimal", scale=2) */    protected $price;

 /** @ORM\Column(type="text") */    protected $description;}

http://symfony.com

twitter.com/glennguden