Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introducing Symfony Composer, Bundles, Symfony Framework Georgi Gyurov

Similar presentations


Presentation on theme: "Introducing Symfony Composer, Bundles, Symfony Framework Georgi Gyurov"— Presentation transcript:

1 Introducing Symfony Composer, Bundles, Symfony Framework Georgi Gyurov
Software University

2 Table of Contents Introducing Symfony Install Symfony Composer
Symfony installer Symfony Overview

3 Have a question? #sli.do #softuni-symfony

4 About Stenik Founded in 2004 Main areas of expertise
E-Commerce solutions Corporate Web Sites and Applications Custom Design Small company with young team Compelling projects and great customers 4

5 Course: Out of Scope We will not learn things like:
PHP Programming language OOP Databases HTML/CSS/Javascript LAMP/XAMPP setup and troubleshouting Those are required skills you should have prior attending this course 5

6 Course Goals Become familiar with Symfony
Learn the MVC approach and configurations in Symfony Learn how to create bundles Have knowledge of advanced mechanisms and possibilities of the platform 6

7 Assesment 80 points from course projects 7

8 Advantages of The Framework
Introducing Symfony Advantages of The Framework

9 Sample Magento Stores kinoarena.com tokudabank.bg kontrax.bg
service.skoda-auto.bg 9

10 Introducing Symfony MVC Architecture Great Set of Components
Active community Good documentation

11 Install & Configure Symfony
Composer

12 Run Symfony Creating vhost

13 Composer Introduction
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. To install Composer go to and follow instructions.

14 Composer Install Symfony with Composer:
php composer.phar create-project symfony/framework-standard-edition my_project_name php composer.phar create-project symfony/framework-standard-edition my_project_name “3.2.*" composer create-project symfony/framework-standard-edition symfony-project "3.2.*" Installing symfony/framework-standard-edition (v3.2.8) - Installing symfony/framework-standard-edition (v3.2.8) Downloading: 100% Created project in symfony-project Loading composer repositories with package information

15 Run Symfony To check configuration symfony.localhost/config.php

16 Run Symfony Setting up permissions
Linux HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX var macOS rm -rf var/cache/* rm -rf var/logs/* HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1` sudo chmod -R +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" var sudo chmod -R +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" var Windows umask(0002); // This will let the permissions be 0775 // or umask(0000); // This will let the permissions be 0777

17 Welcome to Symfony

18 Practise: Install Symfony
Live Exercise In Class (Lab)

19 First Steps With The Framework
Symfony Overview First Steps With The Framework

20 The Bundle System What is a Bundle?
set of files within a directory designed to imlpement a single feature each bundle has its own namespace \<Vendor Name>\(<Namespace>\)*<Class Name>

21 The Bundle System The bundle class name must follow five simple rules:
Use only alphanumeric characters and underscores; Use a CamelCase name; Use a descriptive and short name (no more than two words); Prefix the name with the concatenation of the vendor (and optionally the category namespaces); Suffix the name with Bundle.

22 The Bundle System Example of valid bundle names: Namespace
Bundle Class Name Stenik\BlogBundle\StenikBlogBundle StenikBlogBundle Stenik\ServicesBundle\StenikServicesBundle StenikServicesBundle

23 Directory Structure Directory Description var/ logs and cache files
vendor/ dependecies (bundles) src/ the project’s code (own bundles) Web/ Web root directory, application index app/ Application Kernel and configuration files bin/ Symfony console tests/ Automatic tests

24 Symfony Project Overview
app/AppKernel.php Is the most important file of our project All bundles are registered/activated in AppKernel class AppKernel extends Kernel { public function registerBundles() { $bundles = [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), ]; //TO DO }

25 Symfony Project Overview
app/AppKernel.php AppKernel also provides configuration for different environments class AppKernel extends Kernel { public function registerBundles() { //TO DO if (in_array($this->getEnvironment(), ['dev', 'test'])) { $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); } Each environment should have its own config file suffixed with the name of the provided environment, e.g.: config_dev.yml Each environment creates its own cache and log files in var/cache and var/log

26 YAML YAML is: human-readable data serialization language like json and xml, but easier to read based on key: value used for Symfony configuration

27 Symfony Project Overview
app/config/config.yml Application main config file for application settings framework: templating: engines: [‘twig’] imports: - { resource: parameters.yml } - { resource: security.yml } - { resource: services.yml } - { resource: }

28 Symfony Project Overview
app/config/parameters.yml Infrastructure-related configuration like database settings and mail service parameters: database_host: localhost database_name: symfony dabatase_user: root database_pass: custom_param: param_value

29 Symfony Routing app/config/routing.yml
Contains mapping between controllers and routes user_profile: path: /user/profile defaults: { _controller: AppBundle:User:profile } services_bundle: resource: type: annotation prefix: /{_locale} requirements: _locale: "[a-z]{2}"

30 Symfony Routing Parameters
app/config/routing.yml _controller This parameter is used to determine which controller is executed when the route is matched. _format Used to set the request format (read more). _locale Used to set the locale on the request (read more).

31 Trying some code git clone

32 Summary Symfony is leading PHP framework to create websites and web applications. Built on top of the Symfony Components A bundle is similar to a plugin in other software, but even better. The key difference is that everything is a bundle in Symfony, including both the core framework functionality and the code written for your application. Bundles are first-class citizens in Symfony Large Community Highly scalable 32 © Software University Foundation – This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 32

33 https://softuni.bg/courses/
© Software University Foundation – This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 33

34 License This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International" license 34 © Software University Foundation – This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 34

35 Trainings @ Software University (SoftUni)
Software University – High-Quality Education, Profession and Job for Software Developers softuni.bg Software University Foundation softuni.org Software Facebook facebook.com/SoftwareUniversity Software University Forums forum.softuni.bg © Software University Foundation – This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike license. 35


Download ppt "Introducing Symfony Composer, Bundles, Symfony Framework Georgi Gyurov"

Similar presentations


Ads by Google