Docsity

Introducing Symfony Composer, Bundles, Symfony Framework, Lecture notes of Web Design and Development

Partial preview of the text

Download Introducing Symfony Composer, Bundles, Symfony Framework and more Lecture notes Web Design and Development in PDF only on Docsity!

Introducing Symfony

Composer, Bundles, Symfony Framework

  • Introducing Symfony
  • Install Symfony
    • Symfony Installer
    • Composer
  • Symfony Overview Table of Contents 2
  • MVC Architecture
  • Scalability
  • Great Set of Components
  • Active community
  • Good documentation Introducing Symfony 4

INSTALL & CONFIGURE SYMFONY Symfony Installer & Composer

  • To install Composer go to

https://getcomposer.org/download/

and follow instructions.

Composer

  • Install Symfony: go to https://symfony.com/download Composer 8

Run Symfony

SYMFONY OVERVIEW First Steps With The Framework 11

  • 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. The Bundle System 13
  • Example of valid bundle names: The Bundle System

Directory Structure 16 Directory Description app/ Application Kernel (AppKernel) and main configuration files in config/ directory bin/ Symfony console src/ the project’s code tests/ automatic(unit) tests

Directory Structure Directory Description var/ logs and cache files vendor third-party dependecies (bundles) src/ the project’s code web/ web root directory, application index

  • src/Kernel.php
    • AppKernel also provides configuration for different environments Symfony Project Overview class Kernel extends BaseKernel { public function registerBundles() { $contents = require $this->getProjectDir().'/config/bundles.php'; foreach ($contents as $class => $envs) { if ($envs[$this->environment] ?? $envs['all'] ?? false) { yield new $class(); } } } } 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
  • app/config/routes.yaml
    • Contains mapping between controllers and routes Symfony Project Overview

This file is the entry point to configure your own HTTP routes.

Files in the routes/ subdirectory configure the routes for your dependencies.

#index:

path: /

defaults: { _controller: 'App\Controller\DefaultController::index' }