PHP Frameworks and Symfony

16
Symfony

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

Page 1: PHP Frameworks and Symfony

Symfony

Page 2: PHP Frameworks and 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)

Page 3: PHP Frameworks and Symfony

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 

Page 4: PHP Frameworks and Symfony

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

Page 5: PHP Frameworks and Symfony

some Symfony features...

Support for multiple platforms

Scaffolding - for CRUD templates

multilingualism and I18N support

Database Engine Independent

cache management

Page 6: PHP Frameworks and Symfony

Reasons to use Symfony1. Reputation

2. Permanence

3. References

4. Innovation

5. Resources

6. Interoperability

Page 7: PHP Frameworks and Symfony

Installation: www.symfony.com

Download, Extract, Start

Page 8: PHP Frameworks and Symfony

What is inside?

Page 9: PHP Frameworks and Symfony

Console Commands

Page 10: PHP Frameworks and Symfony

Welcome!

Page 11: PHP Frameworks and Symfony

Creating Pages in Symfony2

1. Create a route2. Create a controller

Page 12: PHP Frameworks and Symfony

Routing (smart URLs )

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

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

Page 13: PHP Frameworks and Symfony

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>');

    }

}

Page 14: PHP Frameworks and Symfony

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;}

Page 15: PHP Frameworks and Symfony

http://symfony.com

Page 16: PHP Frameworks and Symfony

twitter.com/glennguden