The document discusses dependency injection (DI) in PHP. It provides an overview of common DI containers and frameworks used in PHP projects, including Pimple, Bucket, Zend\Di, and Symfony. For each option, it demonstrates basic usage including constructor injection, setter injection, and retrieving services from the container. It also discusses concepts like shared services, configuration via XML, and injecting dependencies via interfaces or properties. The document serves as a high-level introduction to dependency injection in PHP.
This document contains sample questions for the Zend Certification PHP 5 exam. It includes multiple choice questions testing PHP 5 language features and best practices related to topics like XML processing, database access, regular expressions, and security. The questions cover syntax, functions, patterns and other PHP concepts that could appear on the certification exam.
This document contains a practice exam with 18 multiple choice questions about PHP functions and concepts. It is registered to Núria Torrescasana of Manresa, Barcelona, Spain. The questions cover topics like PHP functions, arrays, classes, sessions, strings, dates/time, and file handling. The answers to the questions are provided at the end.
PHP Basic and Fundamental Questions and Answers with Detail ExplanationAbdul Rahman Sherzad
These PHP basic and fundamental questions and answers with detail explanation help students and learners to think comprehensive, and to seek more to understand the concept and the root of each topic concretely.
WordPress plugin localization is extremely simple. This presentation will show you how to localize a WordPress plugin and show you some pretty advanced functions for helping your translators.
With PHP5.3.3 recently released I really feel it is time that php developers are taking namespaces seriously. If you don’t I guarantee you will be out of a job within five years. Namespaces are a fundamental part of the future of PHP. The talk explains the usage on importing third party libraries, using it in your own code and aliasing. The full works.
Full-day tutorial for the dutch php conference 2011 giving a very quick tour around all the various areas of the ZCE syllabus and some tips on the exam styles
PHP functions allow programmers to divide code into reusable pieces. There are three main types of functions: simple functions that don't take arguments, functions with parameters that allow passing data into the function, and functions with return values that return data out of the function. Functions make code more organized and reusable.
The document discusses different types of dead code in PHP applications, including unreachable code, useless variables, PHP-specific issues, and structural dead code. It provides examples of each type and explains how to identify and remove dead code to make code more maintainable and efficient. The speaker is the CTO of Exakat, a company that provides static code analysis for PHP to help find dead and unused code.
This document contains sample questions for the Zend Certification PHP 5 exam. It includes multiple choice questions testing PHP 5 language features and best practices related to topics like XML processing, database access, regular expressions, and security. The questions cover syntax, functions, patterns and other PHP concepts that could appear on the certification exam.
This document contains a practice exam with 18 multiple choice questions about PHP functions and concepts. It is registered to Núria Torrescasana of Manresa, Barcelona, Spain. The questions cover topics like PHP functions, arrays, classes, sessions, strings, dates/time, and file handling. The answers to the questions are provided at the end.
PHP Basic and Fundamental Questions and Answers with Detail ExplanationAbdul Rahman Sherzad
These PHP basic and fundamental questions and answers with detail explanation help students and learners to think comprehensive, and to seek more to understand the concept and the root of each topic concretely.
WordPress plugin localization is extremely simple. This presentation will show you how to localize a WordPress plugin and show you some pretty advanced functions for helping your translators.
With PHP5.3.3 recently released I really feel it is time that php developers are taking namespaces seriously. If you don’t I guarantee you will be out of a job within five years. Namespaces are a fundamental part of the future of PHP. The talk explains the usage on importing third party libraries, using it in your own code and aliasing. The full works.
Full-day tutorial for the dutch php conference 2011 giving a very quick tour around all the various areas of the ZCE syllabus and some tips on the exam styles
PHP functions allow programmers to divide code into reusable pieces. There are three main types of functions: simple functions that don't take arguments, functions with parameters that allow passing data into the function, and functions with return values that return data out of the function. Functions make code more organized and reusable.
The document discusses different types of dead code in PHP applications, including unreachable code, useless variables, PHP-specific issues, and structural dead code. It provides examples of each type and explains how to identify and remove dead code to make code more maintainable and efficient. The speaker is the CTO of Exakat, a company that provides static code analysis for PHP to help find dead and unused code.
PHP originated as a tool for personal home pages created by Rasmus Lerdorf. It is now known as the PHP Hypertext Processor and is an open source, scripting language commonly used for web development. PHP scripts can be embedded into HTML pages and allow for easy access to form data and output of dynamic HTML. PHP is a procedural language like C with some object-oriented features. It has an extensive function library that supports tasks like string handling, dates/times, files, databases and more. PHP follows a model where scripts run on the server and generate HTML to be sent to the client browser.
The document discusses several software development best practices including source control, coding standards, design patterns, documentation, testing, and deployment. It provides examples and explanations of common design patterns like factory, registry, adapter, decorator, and observer. Resources for further information on topics like Subversion, Git, coding standards, and design patterns are also referenced.
From ReactPHP to Facebook Hack's Async implementation and many more, asynchronous programming has been a 'hot' topic lately. But how well does async programming support work in PHP and what can you actually use it for in your projects ? Let's look at some real-world use cases and how they leverage the power of async to do things you didn't know PHP could do.
This document provides a quick introduction to the C programming language. It discusses basic C syntax like main functions, header files, comments, and variables. It also covers data types, memory, functions, scopes, expressions, control flow statements like if/else and loops. Functions can access arguments and global variables from their own scope but not variables from outer scopes unless passing their addresses.
Everyone talks about raising the bar on the quality of code, but it’s hard to implement when you have no clue where to start. This talk is geared toward all levels of developers, and will teach you how to improve by using the right tools effectively – a must-attend for any PHP developer who wants to scale up their quality.
Michelangelo will tell us about Quality Assurance for PHP in general and show how different QA-related actions can be performed using PhpStorm IDE. The webinar will cover topics including:
Revision control
Syntax checking
Code documentation
Unit Testing with PHPUnit
Measuring code health with a variety of tools
Profiling and debugging with Xdebug
Automation with Phing
Team work and more.
This document discusses basic shell scripting in Unix. It covers different shell types in Unix like Bourne shell, bash, c-shell, korn shell, and tc shell. It describes how to execute shell scripts and discusses command line editing. The document also covers basic vi commands, entering and changing text, deletion commands, and moving around in the history file. Additionally, it discusses shell variables like positional parameters, special parameters, and named variables. Other topics covered include accepting user input, displaying data, comments, test commands, logical operators, and the expr command.
This document provides an overview of dependency injection (DI) and how it is implemented in Drupal 8. It begins by explaining DI as a design pattern that allows code to be more reusable, testable and ignorant of dependencies. It then discusses how frameworks like Symfony implement DI using a service container that is configured to inject dependencies. In Drupal 8, services are defined in YAML files and the container is configured using compiler passes. Core services can be accessed directly or by wiring classes into the container as event subscribers or using a factory method for controllers.
PHP is a scripting language commonly used for web development. It allows dynamic generation of web page content through embedded PHP code. Some key things PHP can do include interacting with databases, processing user input, file handling, and more. PHP code is embedded within HTML using <?php ?> tags and variables, control structures, and other programming elements allow writing logic and dynamic functionality.
This document provides an overview of object-oriented programming (OOP) concepts in PHP. It discusses key OOP features like classes, objects, inheritance, encapsulation, abstraction, and interfaces. It explains why OOP is useful for modularity, abstraction, information hiding, structured design, hierarchy, and continuity. Main language features in PHP like classes, inheritance, visibility, abstraction, interfaces, and polymorphism are also covered. Real-world examples of classes, objects, inheritance and interfaces in PHP code are provided.
The document summarizes an advanced Perl training course covering new features in Perl 5.10 like defined-or operator, switch statement, smart matching and say(), as well as testing with modules like Test::MockObject, profiling with Devel::Cover, and benchmarking code with Benchmark.pm. The one-day course will quickly cover many Perl topics and point to additional online resources for further learning.
This document provides information about PHP (Hypertext Preprocessor), which is a server-side scripting language used for web development. It discusses that PHP scripts are executed on the server, PHP supports many databases, and it is an open source software. The document also explains why PHP is used, where to start with PHP, basic PHP syntax, variables, operators, conditional statements, loops, arrays, functions, forms, connecting to databases, and creating databases and tables. It provides examples of PHP code for many of these concepts to demonstrate how PHP works.
Perl is an interpreted programming language created in 1987 that provides powerful text processing capabilities. It is portable, supports rapid prototyping, and follows the philosophy of "there's more than one way to do it". To use Perl, it needs to be installed which is usually already done on Linux and Mac systems. Common Perl data types include numbers, strings, and scalar variables to store single values. Perl includes typical operators for mathematics and strings, and conditional statements like if/else to control program execution based on comparisons.
The document provides an overview of how a simple C "Hello World" program works, from writing the code to executing the compiled binary. It includes explanations of key concepts like #include, main(), printf(), compiling with gcc, the a.out executable, and how the operating system loads and runs the program. The summary explores the high-level process of taking C code and turning it into a running program.
The document discusses inheritance and virtual functions in C++. It defines inheritance as a mechanism where one class acquires properties from another class. There are different types of inheritance including single, multiple, hierarchical, and multilevel inheritance. Virtual functions allow polymorphic behavior where calling code does not need to know the exact type of an object. The key properties of virtual functions are that they can be overridden in derived classes and the overridden version will be called depending on the actual object type.
This document summarizes the evolution of PHP from issues with early versions like inconsistent naming and unpredictable releases to recent improvements like namespaces, anonymous functions, and a standardized release cycle. It discusses tools for PHP development like Composer and FIG as well as educational resources. Key points covered include PHP's move to namespaces in 5.3, anonymous functions in 5.4, and built-in password hashing in 5.5. FIG standards like PSR-0 help code sharing while Composer eases dependency management.
This document provides an overview of Linux command line essentials including shell script basics, variables, operators, loops, and functions. It covers topics such as the difference between CLI and GUI interfaces, what a kernel and shell are, defining variables and variable types, arithmetic, relational, boolean, and file test operators, while, for, and until loops, and creating reusable functions. The document is from edureka.co and serves as an introduction to common Linux shell scripting concepts.
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf Conference
Capistrano для деплоймента PHP приложений
Capistrano is a tool for deploying PHP applications. It allows deployments to be done with a single command. Capistrano handles tasks like updating files and databases, creating files/folders/symlinks, file permissions, cache clearing, and rolling back if errors occur. Common methods for deployment include FTP clients, version control hooks, Phing, shell scripts, and Rsync. Capistrano uses SSH and works with version control systems like Git, SVN, and Mercurial. It manages releases by creating dated directories and symlinking the current release. Custom tasks can be added to handle additional deployment steps.
This document discusses using Gradle for building projects in multiple languages. Gradle's domain specific language is based on Groovy, which allows for concise syntax. Gradle supports building Java, C++, Ruby, and other languages through plugins. It can also be used to build documentation and publish artifacts to repositories. Migrating from other build systems like Ant, Maven, and Make to Gradle is also discussed.
Virtual functions allow dynamic binding to occur. This means that the function called is determined at runtime based on the actual object type, rather than static binding which determines the function at compile time. Some key points:
1) A virtual function tells the compiler to create a pointer to the function but not fill it in until called.
2) Classes with virtual functions are called polymorphic classes and allow overriding derived class functions.
3) Virtual functions are useful for polymorphism when subclasses need to provide unique implementations of the same method name.
This document discusses the history and current state of dependency injection (DI) in PHP. It provides an overview of DI principles and frameworks that have supported DI over the years such as Spring Framework, Symfony, and Zend Framework. The document then demonstrates how to implement DI using the Zend\Di and Symfony containers through examples of constructor injection, setter injection, interface injection and more.
Practical tips for dealing with projects involving legacy code. Covers investigating past projects, static analysis of existing code, and methods for changing legacy code.
Presented at PHP Benelux '10
PHP originated as a tool for personal home pages created by Rasmus Lerdorf. It is now known as the PHP Hypertext Processor and is an open source, scripting language commonly used for web development. PHP scripts can be embedded into HTML pages and allow for easy access to form data and output of dynamic HTML. PHP is a procedural language like C with some object-oriented features. It has an extensive function library that supports tasks like string handling, dates/times, files, databases and more. PHP follows a model where scripts run on the server and generate HTML to be sent to the client browser.
The document discusses several software development best practices including source control, coding standards, design patterns, documentation, testing, and deployment. It provides examples and explanations of common design patterns like factory, registry, adapter, decorator, and observer. Resources for further information on topics like Subversion, Git, coding standards, and design patterns are also referenced.
From ReactPHP to Facebook Hack's Async implementation and many more, asynchronous programming has been a 'hot' topic lately. But how well does async programming support work in PHP and what can you actually use it for in your projects ? Let's look at some real-world use cases and how they leverage the power of async to do things you didn't know PHP could do.
This document provides a quick introduction to the C programming language. It discusses basic C syntax like main functions, header files, comments, and variables. It also covers data types, memory, functions, scopes, expressions, control flow statements like if/else and loops. Functions can access arguments and global variables from their own scope but not variables from outer scopes unless passing their addresses.
Everyone talks about raising the bar on the quality of code, but it’s hard to implement when you have no clue where to start. This talk is geared toward all levels of developers, and will teach you how to improve by using the right tools effectively – a must-attend for any PHP developer who wants to scale up their quality.
Michelangelo will tell us about Quality Assurance for PHP in general and show how different QA-related actions can be performed using PhpStorm IDE. The webinar will cover topics including:
Revision control
Syntax checking
Code documentation
Unit Testing with PHPUnit
Measuring code health with a variety of tools
Profiling and debugging with Xdebug
Automation with Phing
Team work and more.
This document discusses basic shell scripting in Unix. It covers different shell types in Unix like Bourne shell, bash, c-shell, korn shell, and tc shell. It describes how to execute shell scripts and discusses command line editing. The document also covers basic vi commands, entering and changing text, deletion commands, and moving around in the history file. Additionally, it discusses shell variables like positional parameters, special parameters, and named variables. Other topics covered include accepting user input, displaying data, comments, test commands, logical operators, and the expr command.
This document provides an overview of dependency injection (DI) and how it is implemented in Drupal 8. It begins by explaining DI as a design pattern that allows code to be more reusable, testable and ignorant of dependencies. It then discusses how frameworks like Symfony implement DI using a service container that is configured to inject dependencies. In Drupal 8, services are defined in YAML files and the container is configured using compiler passes. Core services can be accessed directly or by wiring classes into the container as event subscribers or using a factory method for controllers.
PHP is a scripting language commonly used for web development. It allows dynamic generation of web page content through embedded PHP code. Some key things PHP can do include interacting with databases, processing user input, file handling, and more. PHP code is embedded within HTML using <?php ?> tags and variables, control structures, and other programming elements allow writing logic and dynamic functionality.
This document provides an overview of object-oriented programming (OOP) concepts in PHP. It discusses key OOP features like classes, objects, inheritance, encapsulation, abstraction, and interfaces. It explains why OOP is useful for modularity, abstraction, information hiding, structured design, hierarchy, and continuity. Main language features in PHP like classes, inheritance, visibility, abstraction, interfaces, and polymorphism are also covered. Real-world examples of classes, objects, inheritance and interfaces in PHP code are provided.
The document summarizes an advanced Perl training course covering new features in Perl 5.10 like defined-or operator, switch statement, smart matching and say(), as well as testing with modules like Test::MockObject, profiling with Devel::Cover, and benchmarking code with Benchmark.pm. The one-day course will quickly cover many Perl topics and point to additional online resources for further learning.
This document provides information about PHP (Hypertext Preprocessor), which is a server-side scripting language used for web development. It discusses that PHP scripts are executed on the server, PHP supports many databases, and it is an open source software. The document also explains why PHP is used, where to start with PHP, basic PHP syntax, variables, operators, conditional statements, loops, arrays, functions, forms, connecting to databases, and creating databases and tables. It provides examples of PHP code for many of these concepts to demonstrate how PHP works.
Perl is an interpreted programming language created in 1987 that provides powerful text processing capabilities. It is portable, supports rapid prototyping, and follows the philosophy of "there's more than one way to do it". To use Perl, it needs to be installed which is usually already done on Linux and Mac systems. Common Perl data types include numbers, strings, and scalar variables to store single values. Perl includes typical operators for mathematics and strings, and conditional statements like if/else to control program execution based on comparisons.
The document provides an overview of how a simple C "Hello World" program works, from writing the code to executing the compiled binary. It includes explanations of key concepts like #include, main(), printf(), compiling with gcc, the a.out executable, and how the operating system loads and runs the program. The summary explores the high-level process of taking C code and turning it into a running program.
The document discusses inheritance and virtual functions in C++. It defines inheritance as a mechanism where one class acquires properties from another class. There are different types of inheritance including single, multiple, hierarchical, and multilevel inheritance. Virtual functions allow polymorphic behavior where calling code does not need to know the exact type of an object. The key properties of virtual functions are that they can be overridden in derived classes and the overridden version will be called depending on the actual object type.
This document summarizes the evolution of PHP from issues with early versions like inconsistent naming and unpredictable releases to recent improvements like namespaces, anonymous functions, and a standardized release cycle. It discusses tools for PHP development like Composer and FIG as well as educational resources. Key points covered include PHP's move to namespaces in 5.3, anonymous functions in 5.4, and built-in password hashing in 5.5. FIG standards like PSR-0 help code sharing while Composer eases dependency management.
This document provides an overview of Linux command line essentials including shell script basics, variables, operators, loops, and functions. It covers topics such as the difference between CLI and GUI interfaces, what a kernel and shell are, defining variables and variable types, arithmetic, relational, boolean, and file test operators, while, for, and until loops, and creating reusable functions. The document is from edureka.co and serves as an introduction to common Linux shell scripting concepts.
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)ZFConf Conference
Capistrano для деплоймента PHP приложений
Capistrano is a tool for deploying PHP applications. It allows deployments to be done with a single command. Capistrano handles tasks like updating files and databases, creating files/folders/symlinks, file permissions, cache clearing, and rolling back if errors occur. Common methods for deployment include FTP clients, version control hooks, Phing, shell scripts, and Rsync. Capistrano uses SSH and works with version control systems like Git, SVN, and Mercurial. It manages releases by creating dated directories and symlinking the current release. Custom tasks can be added to handle additional deployment steps.
This document discusses using Gradle for building projects in multiple languages. Gradle's domain specific language is based on Groovy, which allows for concise syntax. Gradle supports building Java, C++, Ruby, and other languages through plugins. It can also be used to build documentation and publish artifacts to repositories. Migrating from other build systems like Ant, Maven, and Make to Gradle is also discussed.
Virtual functions allow dynamic binding to occur. This means that the function called is determined at runtime based on the actual object type, rather than static binding which determines the function at compile time. Some key points:
1) A virtual function tells the compiler to create a pointer to the function but not fill it in until called.
2) Classes with virtual functions are called polymorphic classes and allow overriding derived class functions.
3) Virtual functions are useful for polymorphism when subclasses need to provide unique implementations of the same method name.
This document discusses the history and current state of dependency injection (DI) in PHP. It provides an overview of DI principles and frameworks that have supported DI over the years such as Spring Framework, Symfony, and Zend Framework. The document then demonstrates how to implement DI using the Zend\Di and Symfony containers through examples of constructor injection, setter injection, interface injection and more.
Practical tips for dealing with projects involving legacy code. Covers investigating past projects, static analysis of existing code, and methods for changing legacy code.
Presented at PHP Benelux '10
The document discusses several design patterns that are commonly used in PHP development, including the Singleton, Factory Method, Adapter, Template Method, and Dependency Injection patterns. It describes what each pattern is used for, provides examples of how to implement each pattern in PHP code, and discusses the benefits and tradeoffs of applying each design pattern. The document serves as a guide for PHP developers to understand and apply these fundamental object-oriented design patterns in their own applications.
This document provides an overview and introduction to Laravel 5, a PHP web application framework. It discusses key Laravel 5 concepts and features such as Eloquent ORM, routing, middleware, contracts, form requests, the IoC container, file drivers, scheduling commands, and the command bus pattern. The document is intended to explain Laravel 5 concepts through code examples and brief explanations.
This document discusses dependency injection in Drupal 8. It begins by explaining the problems with Drupal 7 code, such as strong dependencies on globals and an inability to reuse or test code easily. It then introduces dependency injection as a design pattern that can help address these issues by reducing hard-coded dependencies. The document outlines how dependency injection works in Symfony and will work in Drupal 8 through the use of a service container that allows injecting dependencies into classes.
PHP 8 introduces several new features and backward compatibility breaks. It includes a just-in-time compiler, match expression, constructor property promotion, union types, static return type, attributes, named arguments, and improved type handling. Notable BC breaks are stricter error handling by default, locale independence for float conversions, and warning promotion to type errors. The changes aim to improve performance, type safety, and consistency.
This document summarizes some new features in PHP 5.4:
- Array syntax can now be written more concisely using square brackets instead of array functions.
- PHP 5.4 includes a built-in web server for development purposes, allowing PHP scripts to be run without Apache.
- Traits allow sharing of methods across classes to reduce code duplication, similar to mixins in Ruby.
- Closures now support accessing properties of the enclosing class scope via $this.
The document discusses hexagonal architecture and how it can be applied to PHP applications. It begins by defining software architecture and its importance. It then explains hexagonal architecture, which separates an application into distinct layers including domain, application, and infrastructure layers. The layers are decoupled via defined boundaries and interfaces. Commands are used to communicate between layers and are handled by command buses and handlers. Examples are given of implementing repositories, commands and handlers to follow this pattern in a PHP application.
PHP 7 is a major release that provides significant performance improvements over PHP 5, making PHP 7 as fast as or faster than HHVM. It removes deprecated features and provides new features like scalar type hints, return type hints, the spaceship and coalesce operators, anonymous classes, and group use declarations. Developers are encouraged to test their applications on PHP 7 to take advantage of these improvements and prepare for the future of PHP.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
The document discusses building custom PHP extensions. It covers setting up a development environment, creating extension skeletons using automated tools, building and installing extensions, and key extension internals like implementing and exposing C functions and PHP parameter parsing. The talk provides an example of a URI template extension the speaker created, explaining what it does, how to use it, and why extensions are important. It also discusses PHP_FUNCTION macro expansion, available parameter types for functions, and how to return values from extensions.
The document provides tips for optimizing PHP code, including using string functions instead of regular expressions where possible, passing references to reduce memory usage, using persistent database connections, and checking mysql_unbuffered_query() for faster queries. It also discusses HTTP requests and responses, cookie expiry, references in PHP, returning references from functions, and the debug_backtrace() function. The document concludes with tips for improving security such as checking for uninitialized variables, validating user input, and restricting access to included files.
This document discusses upgrading from PHP 5 to PHP 7. It begins with an introduction and timeline of PHP versions. It then provides reasons to upgrade such as improved performance, new features like scalar type hints, and deprecated functions being removed. A checklist is provided covering removed functions like mysql_* and ereg* as well as removed ini directives. Upgrade recommendations suggest using frameworks for structure and security. Popular frameworks like Laravel, Symfony and CodeIgniter are mentioned. PDO is recommended over mysql_* for database connectivity.
Build powerfull and smart web applications with Symfony2Hugo Hamon
Symfony2 first stable release is scheduled for the first week of March 2011. During this session, we will have a look at the new framework architecture and most of its powerfull features.
We will show you how Symfony2 implements the MVC pattern and an HTTP request is processed and converted as a response for the end user. Of course, we will talk about the configuration principles and how it's easy to configure Symfony2 project parts like the routing system or the data model. We will also focus on other major components of the framework like the Doctrine2 integration, forms, security (authentication and authorizations) or HTTP cache management.
This document summarizes a presentation about the Zend Framework PHP development framework. It introduces the MVC architecture used in Zend Framework and describes how the framework implements Models using database abstraction, Views using template rendering, and Controllers to dispatch requests. It also discusses how Zend Framework supports web services, Ajax, and other web technologies and includes built-in libraries for common tasks.
Modern PHP has grown significantly over the last 15-20 years and is now suitable for large projects. It supports object oriented programming with classes, interfaces, abstract classes and traits. Types can be hinted and nullable. Large applications can be built with namespaces and dependency management via Composer. Testing, linting and exceptions are also supported. While still allowing procedural code, PHP provides features for building maintainable, scalable software.
Symfony2 è sicuramente uno dei framework migliori in circolazione, ma non sono tutte rose e fiori, soprattutto per chi inizia a sviluppare ed è alle prime armi. In questa presentazione vorrei condividere la mie esperienza di apprendimento ed utilizzo del framework, cercando di mettere in evidenza i miei momenti wtf e alcune linee guida per sviluppare applicazioni manutenibili
This document discusses HTTP middlewares in PHP. It begins by introducing the concept of middlewares and how they allow code to be run before and after each HTTP request is handled. It then provides examples of how to implement middlewares using the Symfony HttpKernel component, including logging, caching, and authentication middlewares. Finally, it promotes a PHP middleware stack called StackPHP that provides common middlewares like sessions, OAuth, CORS, and more to simplify building middleware-based PHP applications.
This document discusses Phing, an open source build tool for PHP projects that is based on Apache Ant. It provides instructions on how to install Phing globally using PEAR or with Composer. It also covers Phing basics like projects, targets, tasks and properties. Additionally, it demonstrates how to write custom tasks in PHP and use property files to customize builds.
Offline strategies for HTML5 web applications - frOSCon8Stephan Hochdörfer
The document discusses various strategies for enabling offline functionality in HTML5 web applications. It begins by introducing the speaker and defining what is meant by "offline" in this context. It then covers application caching using the cache manifest to store static resources locally. Other techniques discussed include storing dynamic data locally using Web Storage, Web SQL Database, IndexedDB, and the File API. For each approach, examples are provided of how to perform common operations like adding, modifying and retrieving data items. The techniques are also compared in terms of advantages and disadvantages.
Offline Strategies for HTML5 Web Applications - oscon13Stephan Hochdörfer
This document discusses various strategies for enabling offline functionality in HTML5 web applications. It begins by explaining the differences between application caching and offline storage. It then covers using the application cache, web storage, web SQL database, IndexedDB, and file API for caching static resources and storing dynamic data locally. It notes pros and cons of each approach as well as browser support limitations. The document aims to help developers choose the best offline solutions for HTML5 applications.
This document discusses dependency injection (DI) and its benefits when applied in real world projects. It defines DI as a pattern that allows removal of hard-coded dependencies and makes dependencies changeable. The document explains that DI improves code reuse, testability, and maintainability by reducing tight coupling between classes. It presents different DI techniques like constructor injection and describes how to configure dependencies using annotations or XML configuration. The benefits of DI mentioned include easy unit testing, supporting multiple configurations of a class, and mocking external services.
The document discusses dependency injection, including what it is, why it is useful, and how it can be implemented. It defines dependency injection as objects receiving their dependencies from external sources rather than creating them internally. This allows for looser coupling, easier testing, and flexibility to use different implementations. The document covers different injection techniques like constructor injection and using a dependency injection container to manage object wiring.
This document discusses domain-specific languages (DSLs) and provides examples of internal and external DSLs. It explains that internal DSLs are implemented within a general-purpose language using techniques like fluent APIs, expression builders, functions, closures, and annotations. External DSLs have greater syntactic freedom but require developing a new language. Both types of DSLs aim to increase productivity by focusing on the domain rather than implementation details. The document also covers code generation from a DSL to executable code.
This document discusses various ways to install and configure Phing, the PHP build tool. It recommends installing Phing globally via PEAR or with Composer. It also covers best practices like using imports to structure targets, defining internal targets, creating custom tasks, prompting for input, and integrating Phing with Jenkins. The document emphasizes following conventions like naming the main build file build.xml and properties file build.properties.
The document discusses various strategies for enabling offline functionality in HTML5 web applications. It begins by describing past approaches like cookies, Flash cookies, and Google Gears. It then introduces the App Cache, which allows caching of static resources, and discusses some limitations. Other approaches covered include storing data locally using the Data URI scheme, Web Storage, and the Web SQL Database for structured storage. Code examples are provided for basic CRUD operations using Web Storage.
This document discusses dependency injection and its real world applications. It begins by defining what dependencies are in software applications. It then discusses that dependencies themselves are not bad, but rather fixed dependencies can be problematic. The document advocates for using dependency injection and abstraction rather than directly instantiating dependencies. It provides examples of implementing constructor, setter, and interface injection. It also discusses using annotations, external configuration files, and internal configuration for dependency injection. The benefits of dependency injection for unit testing and allowing one class to have multiple implementations are covered.
The document discusses strategies for testing code that is otherwise difficult or impossible to test directly. It presents examples of untestable code involving object construction, external resources like databases and web services, and language issues like private methods. For each problem, it proposes solutions like dependency injection, mocking dependencies, overriding language functions, and using aspects and generative programming to make code more testable. The overall message is that writing testable code requires refactoring legacy code or designing new code for testability from the start.
This document provides an overview of the Phing build tool. It discusses what Phing is, how to install Phing using PEAR or Composer, Phing basics like projects, targets, tasks and properties. It provides examples of build files that demonstrate defining multiple targets, target dependencies, calling targets programmatically, using filesets and filters. Finally, it discusses some of the things Phing can be used for, like automating permission changes.
Offline strategies for HTML5 web applications - ConFoo13Stephan Hochdörfer
The document discusses various offline strategies for HTML5 web applications, including application caching, storing data locally using web storage, web SQL databases, and IndexedDB. It provides code examples and explanations of how to cache static resources, add, modify, and remove items from local storage using these different technologies. It also highlights some advantages and disadvantages of each approach.
This document discusses strategies for testing code that is difficult or seemingly impossible to test, known as "untestable code". It provides examples of how to address issues like object construction that relies on external resources, dependencies, private methods, and language limitations. Specific techniques include using autoloading, custom stream wrappers, mocking databases/web services, reflection, and generative programming with frames to dynamically generate test and production code. The overall message is that with the right approaches, even legacy or "untestable" code can be made testable.
The document discusses various strategies for building offline capabilities in HTML5 web applications. It covers using the Application Cache manifest to cache static resources, storing data locally using Web Storage or the Web SQL Database API, and an introduction to the IndexedDB API. It also highlights some gotchas with the Application Cache, such as files always being served from the cache and the need to reload the page to see new resources.
Must Know Postgres Extension for DBA and Developer during MigrationMydbops
Mydbops Opensource Database Meetup 16
Topic: Must-Know PostgreSQL Extensions for Developers and DBAs During Migration
Speaker: Deepak Mahto, Founder of DataCloudGaze Consulting
Date & Time: 8th June | 10 AM - 1 PM IST
Venue: Bangalore International Centre, Bangalore
Abstract: Discover how PostgreSQL extensions can be your secret weapon! This talk explores how key extensions enhance database capabilities and streamline the migration process for users moving from other relational databases like Oracle.
Key Takeaways:
* Learn about crucial extensions like oracle_fdw, pgtt, and pg_audit that ease migration complexities.
* Gain valuable strategies for implementing these extensions in PostgreSQL to achieve license freedom.
* Discover how these key extensions can empower both developers and DBAs during the migration process.
* Don't miss this chance to gain practical knowledge from an industry expert and stay updated on the latest open-source database trends.
Mydbops Managed Services specializes in taking the pain out of database management while optimizing performance. Since 2015, we have been providing top-notch support and assistance for the top three open-source databases: MySQL, MongoDB, and PostgreSQL.
Our team offers a wide range of services, including assistance, support, consulting, 24/7 operations, and expertise in all relevant technologies. We help organizations improve their database's performance, scalability, efficiency, and availability.
Contact us: info@mydbops.com
Visit: https://www.mydbops.com/
Follow us on LinkedIn: https://in.linkedin.com/company/mydbops
For more details and updates, please follow up the below links.
Meetup Page : https://www.meetup.com/mydbops-databa...
Twitter: https://twitter.com/mydbopsofficial
Blogs: https://www.mydbops.com/blog/
Facebook(Meta): https://www.facebook.com/mydbops/
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/temporal-event-neural-networks-a-more-efficient-alternative-to-the-transformer-a-presentation-from-brainchip/
Chris Jones, Director of Product Management at BrainChip , presents the “Temporal Event Neural Networks: A More Efficient Alternative to the Transformer” tutorial at the May 2024 Embedded Vision Summit.
The expansion of AI services necessitates enhanced computational capabilities on edge devices. Temporal Event Neural Networks (TENNs), developed by BrainChip, represent a novel and highly efficient state-space network. TENNs demonstrate exceptional proficiency in handling multi-dimensional streaming data, facilitating advancements in object detection, action recognition, speech enhancement and language model/sequence generation. Through the utilization of polynomial-based continuous convolutions, TENNs streamline models, expedite training processes and significantly diminish memory requirements, achieving notable reductions of up to 50x in parameters and 5,000x in energy consumption compared to prevailing methodologies like transformers.
Integration with BrainChip’s Akida neuromorphic hardware IP further enhances TENNs’ capabilities, enabling the realization of highly capable, portable and passively cooled edge devices. This presentation delves into the technical innovations underlying TENNs, presents real-world benchmarks, and elucidates how this cutting-edge approach is positioned to revolutionize edge AI across diverse applications.
Northern Engraving | Nameplate Manufacturing Process - 2024Northern Engraving
Manufacturing custom quality metal nameplates and badges involves several standard operations. Processes include sheet prep, lithography, screening, coating, punch press and inspection. All decoration is completed in the flat sheet with adhesive and tooling operations following. The possibilities for creating unique durable nameplates are endless. How will you create your brand identity? We can help!
Introduction of Cybersecurity with OSS at Code Europe 2024Hiroshi SHIBATA
I develop the Ruby programming language, RubyGems, and Bundler, which are package managers for Ruby. Today, I will introduce how to enhance the security of your application using open-source software (OSS) examples from Ruby and RubyGems.
The first topic is CVE (Common Vulnerabilities and Exposures). I have published CVEs many times. But what exactly is a CVE? I'll provide a basic understanding of CVEs and explain how to detect and handle vulnerabilities in OSS.
Next, let's discuss package managers. Package managers play a critical role in the OSS ecosystem. I'll explain how to manage library dependencies in your application.
I'll share insights into how the Ruby and RubyGems core team works to keep our ecosystem safe. By the end of this talk, you'll have a better understanding of how to safeguard your code.
"Choosing proper type of scaling", Olena SyrotaFwdays
Imagine an IoT processing system that is already quite mature and production-ready and for which client coverage is growing and scaling and performance aspects are life and death questions. The system has Redis, MongoDB, and stream processing based on ksqldb. In this talk, firstly, we will analyze scaling approaches and then select the proper ones for our system.
Conversational agents, or chatbots, are increasingly used to access all sorts of services using natural language. While open-domain chatbots - like ChatGPT - can converse on any topic, task-oriented chatbots - the focus of this paper - are designed for specific tasks, like booking a flight, obtaining customer support, or setting an appointment. Like any other software, task-oriented chatbots need to be properly tested, usually by defining and executing test scenarios (i.e., sequences of user-chatbot interactions). However, there is currently a lack of methods to quantify the completeness and strength of such test scenarios, which can lead to low-quality tests, and hence to buggy chatbots.
To fill this gap, we propose adapting mutation testing (MuT) for task-oriented chatbots. To this end, we introduce a set of mutation operators that emulate faults in chatbot designs, an architecture that enables MuT on chatbots built using heterogeneous technologies, and a practical realisation as an Eclipse plugin. Moreover, we evaluate the applicability, effectiveness and efficiency of our approach on open-source chatbots, with promising results.
In the realm of cybersecurity, offensive security practices act as a critical shield. By simulating real-world attacks in a controlled environment, these techniques expose vulnerabilities before malicious actors can exploit them. This proactive approach allows manufacturers to identify and fix weaknesses, significantly enhancing system security.
This presentation delves into the development of a system designed to mimic Galileo's Open Service signal using software-defined radio (SDR) technology. We'll begin with a foundational overview of both Global Navigation Satellite Systems (GNSS) and the intricacies of digital signal processing.
The presentation culminates in a live demonstration. We'll showcase the manipulation of Galileo's Open Service pilot signal, simulating an attack on various software and hardware systems. This practical demonstration serves to highlight the potential consequences of unaddressed vulnerabilities, emphasizing the importance of offensive security practices in safeguarding critical infrastructure.
High performance Serverless Java on AWS- GoTo Amsterdam 2024Vadym Kazulkin
Java is for many years one of the most popular programming languages, but it used to have hard times in the Serverless community. Java is known for its high cold start times and high memory footprint, comparing to other programming languages like Node.js and Python. In this talk I'll look at the general best practices and techniques we can use to decrease memory consumption, cold start times for Java Serverless development on AWS including GraalVM (Native Image) and AWS own offering SnapStart based on Firecracker microVM snapshot and restore and CRaC (Coordinated Restore at Checkpoint) runtime hooks. I'll also provide a lot of benchmarking on Lambda functions trying out various deployment package sizes, Lambda memory settings, Java compilation options and HTTP (a)synchronous clients and measure their impact on cold and warm start times.
AppSec PNW: Android and iOS Application Security with MobSFAjin Abraham
Mobile Security Framework - MobSF is a free and open source automated mobile application security testing environment designed to help security engineers, researchers, developers, and penetration testers to identify security vulnerabilities, malicious behaviours and privacy concerns in mobile applications using static and dynamic analysis. It supports all the popular mobile application binaries and source code formats built for Android and iOS devices. In addition to automated security assessment, it also offers an interactive testing environment to build and execute scenario based test/fuzz cases against the application.
This talk covers:
Using MobSF for static analysis of mobile applications.
Interactive dynamic security assessment of Android and iOS applications.
Solving Mobile app CTF challenges.
Reverse engineering and runtime analysis of Mobile malware.
How to shift left and integrate MobSF/mobsfscan SAST and DAST in your build pipeline.
Main news related to the CCS TSI 2023 (2023/1695)Jakub Marek
An English 🇬🇧 translation of a presentation to the speech I gave about the main changes brought by CCS TSI 2023 at the biggest Czech conference on Communications and signalling systems on Railways, which was held in Clarion Hotel Olomouc from 7th to 9th November 2023 (konferenceszt.cz). Attended by around 500 participants and 200 on-line followers.
The original Czech 🇨🇿 version of the presentation can be found here: https://www.slideshare.net/slideshow/hlavni-novinky-souvisejici-s-ccs-tsi-2023-2023-1695/269688092 .
The videorecording (in Czech) from the presentation is available here: https://youtu.be/WzjJWm4IyPk?si=SImb06tuXGb30BEH .
Dandelion Hashtable: beyond billion requests per second on a commodity serverAntonios Katsarakis
This slide deck presents DLHT, a concurrent in-memory hashtable. Despite efforts to optimize hashtables, that go as far as sacrificing core functionality, state-of-the-art designs still incur multiple memory accesses per request and block request processing in three cases. First, most hashtables block while waiting for data to be retrieved from memory. Second, open-addressing designs, which represent the current state-of-the-art, either cannot free index slots on deletes or must block all requests to do so. Third, index resizes block every request until all objects are copied to the new index. Defying folklore wisdom, DLHT forgoes open-addressing and adopts a fully-featured and memory-aware closed-addressing design based on bounded cache-line-chaining. This design offers lock-free index operations and deletes that free slots instantly, (2) completes most requests with a single memory access, (3) utilizes software prefetching to hide memory latencies, and (4) employs a novel non-blocking and parallel resizing. In a commodity server and a memory-resident workload, DLHT surpasses 1.6B requests per second and provides 3.5x (12x) the throughput of the state-of-the-art closed-addressing (open-addressing) resizable hashtable on Gets (Deletes).
Fueling AI with Great Data with Airbyte WebinarZilliz
This talk will focus on how to collect data from a variety of sources, leveraging this data for RAG and other GenAI use cases, and finally charting your course to productionalization.
The Department of Veteran Affairs (VA) invited Taylor Paschal, Knowledge & Information Management Consultant at Enterprise Knowledge, to speak at a Knowledge Management Lunch and Learn hosted on June 12, 2024. All Office of Administration staff were invited to attend and received professional development credit for participating in the voluntary event.
The objectives of the Lunch and Learn presentation were to:
- Review what KM ‘is’ and ‘isn’t’
- Understand the value of KM and the benefits of engaging
- Define and reflect on your “what’s in it for me?”
- Share actionable ways you can participate in Knowledge - - Capture & Transfer
2. The state of DI in PHP
About me
Stephan Hochdörfer, bitExpert AG
Department Manager Research Labs
enjoying PHP since 1999
7 years of DI experience (in PHP)
S.Hochdoerfer@bitExpert.de
@shochdoerfer
27. The state of DI in PHP
Pimple – First steps
<?php
class TalkService {
public function __construct() {
}
public function getTalks() {
}
}
28. The state of DI in PHP
Pimple – First steps
<?php
require_once '/path/to/Pimple.php';
require_once '/path/to/TalkService.php';
// create the Container
$container = new Pimple();
// define talkService object in container
$container['talkService'] = function ($c) {
return new TalkService();
};
// instantiate talkService from container
$talkService = $container['talkService'];
29. The state of DI in PHP
Pimple – Constructor Injection
<?php
interface GenericRepository {
public function readTalks();
}
class TalkRepository implements GenericRepository {
public function readTalks() {
}
}
class TalkService {
public function __construct(TalkRepository $repo) {
}
public function getTalks() {
}
}
30. The state of DI in PHP
Pimple – Constructor Injection
<?php
require_once '/path/to/Pimple.php';
require_once '/path/to/TalkService.php';
// create the Container
$container = new Pimple();
// define services in container
$container['talkRepository'] = function ($c) {
return new TalkRepository();
};
$container['talkService'] = function ($c) {
return new TalkService($c['talkRepository']);
};
// instantiate talkService from container
$talkService = $container['talkService'];
31. The state of DI in PHP
Pimple – Setter Injection
<?php
class Logger {
public function doLog($logMsg) {
}
}
class TalkService {
public function __construct(TalkRepository $repo) {
}
public function setLogger(Logger $logger) {
}
public function getTalks() {
}
}
32. The state of DI in PHP
Pimple – Setter Injection
<?php
require_once '/path/to/Pimple.php';
require_once '/path/to/TalkService.php';
// create the Container
$container = new Pimple();
// define services in container
$container['logger'] = function ($c) {
return new Logger();
};
$container['talkRepository'] = function ($c) {
return new TalkRepository();
};
$container['talkService'] = function ($c) {
$service = new TalkService($c['talkRepository']);
$service->setLogger($c['logger']);
return $service;
};
// instantiate talkService from container
$talkService = $container['talkService'];
33. The state of DI in PHP
Pimple – General usage
<?php
require_once '/path/to/Pimple.php';
require_once '/path/to/TalkService.php';
// create the Container
$container = new Pimple();
// define services in container
$container['loggerShared'] = $c->share(function ($c) {
return new Logger();
)};
$container['logger'] = function ($c) {
return new Logger();
};
// instantiate logger from container
$logger = $container['logger'];
// instantiate shared logger from container (same instance!)
$logger2 = $container['loggerShared'];
$logger3 = $container['loggerShared'];
35. The state of DI in PHP
Bucket – Constructor Injection
<?php
interface GenericRepository {
public function readTalks();
}
class TalkRepository implements GenericRepository {
public function readTalks() {
}
}
class TalkService {
public function __construct(TalkRepository $repo) {
}
public function getTalks() {
}
}
36. The state of DI in PHP
Bucket – Constructor Injection
<?php
require_once '/path/to/bucket.inc.php';
require_once '/path/to/TalkService.php';
// create the Container
$container = new bucket_Container();
// instantiate talkService from container
$talkService = $container->create('TalkService');
// instantiate shared instances from container
$talkService2 = $container->get('TalkService');
$talkService3 = $container->get('TalkService');
38. The state of DI in PHP
ZendDi – First steps
<?php
namespace Acme;
class TalkService {
public function __construct() {
}
public function getTalks() {
}
}
39. The state of DI in PHP
ZendDi – First steps
<?php
$di = new ZendDiDi();
$service = $di->get('AcmeTalkService');
$service->getTalks();
40. The state of DI in PHP
ZendDi – Constructor Injection
<?php
namespace Acme;
interface GenericRepository {
public function readTalks();
}
class TalkRepository implements GenericRepository {
public function readTalks() {
}
}
class TalkService {
public function __construct(TalkRepository $repo) {
}
public function getTalks() {
}
}
41. The state of DI in PHP
ZendDi – Constructor Injection
<?php
$di = new ZendDiDi();
$service = $di->get('AcmeTalkService');
$service->getTalks();
42. The state of DI in PHP
ZendDi – Setter Injection
<?php
namespace Acme;
class Logger {
public function doLog($logMsg) {
}
}
class TalkService {
public function __construct(TalkRepository $repo) {
}
public function setLogger(Logger $logger) {
}
public function getTalks() {
}
}
43. The state of DI in PHP
ZendDi – Setter Injection
<?php
$di = new ZendDiDi();
$di->configure(
new ZendDiConfiguration(
array(
'definition' => array(
'class' => array(
'AcmeTalkService' => array(
'setLogger' => array('required' => true)
)
)
)
)
)
);
$service = $di->get('AcmeTalkService');
var_dump($service);
44. The state of DI in PHP
ZendDi – Interface Injection
<?php
namespace Acme;
class Logger {
public function doLog($logMsg) {
}
}
interface LoggerAware {
public function setLogger(Logger $logger);
}
class TalkService implements LoggerAware {
public function __construct(TalkRepository $repo) {
}
public function setLogger(Logger $logger) {
}
public function getTalks() {
}
}
45. The state of DI in PHP
ZendDi – Interface Injection
<?php
$di = new ZendDiDi();
$service = $di->get('AcmeTalkService');
$service->getTalks();
46. The state of DI in PHP
ZendDi – General usage
<?php
$di = new ZendDiDi();
$service = $di->get('AcmeTalkService');
var_dump($service);
$service2 = $di->get('AcmeTalkService');
var_dump($service2); // same instance as $service
$service3 = $di->get(
'AcmeTalkService',
array(
'repo' => new phpbnl12TalkRepository()
)
);
var_dump($service3); // new instance
47. The state of DI in PHP
ZendDi – Builder Definition
<?php
// describe dependency
$dep = new ZendDiDefinitionBuilderPhpClass();
$dep->setName('AcmeTalkRepository');
// describe class
$class = new ZendDiDefinitionBuilderPhpClass();
$class->setName('AcmeTalkService');
// add injection method
$im = new ZendDiDefinitionBuilderInjectionMethod();
$im->setName('__construct');
$im->addParameter('repo', 'AcmeTalkRepository');
$class->addInjectionMethod($im);
// configure builder
$builder = new ZendDiDefinitionBuilderDefinition();
$builder->addClass($dep);
$builder->addClass($class);
48. The state of DI in PHP
ZendDi – Builder Definition
<?php
// add to Di
$defList = new ZendDiDefinitionList($builder);
$di = new ZendDiDi($defList);
$service = $di->get('AcmeTalkService');
var_dump($service);
50. The state of DI in PHP
Symfony2
<?php
namespace AcmeTalkBundleController;
use SymfonyBundleFrameworkBundleControllerController;
use SensioBundleFrameworkExtraBundleConfigurationRoute;
use SensioBundleFrameworkExtraBundleConfigurationTemplate;
class TalkController extends Controller {
/**
* @Route("/", name="_talk")
* @Template()
*/
public function indexAction() {
$service = $this->get('acme.talk.service');
return array();
}
}
51. The state of DI in PHP
Symfony2 – Configuration file
File services.xml in src/Acme/DemoBundle/Resources/config
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
</container>
52. The state of DI in PHP
Symfony2 – Constructor Injection
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.talk.repo"
class="AcmeTalkBundleServiceTalkRepository" />
<service id="acme.talk.service"
class="AcmeTalkBundleServiceTalkService">
<argument type="service" id="acme.talk.repo" />
</service>
</services>
</container>
53. The state of DI in PHP
Symfony2 – Setter Injection
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.talk.logger"
class="AcmeTalkBundleServiceLogger" />
<service id="acme.talk.repo"
class="AcmeTalkBundleServiceTalkRepository" />
<service id="acme.talk.service"
class="AcmeTalkBundleServiceTalkService">
<argument type="service" id="acme.talk.repo" />
<call method="setLogger">
<argument type="service" id="acme.talk.logger" />
</call>
</service>
</services>
</container>
54. The state of DI in PHP
Symfony2 – Setter Injection (optional)
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.talk.logger"
class="AcmeTalkBundleServiceLogger" />
<service id="acme.talk.repo"
class="AcmeTalkBundleServiceTalkRepository" />
<service id="acme.talk.service"
class="AcmeTalkBundleServiceTalkService">
<argument type="service" id="acme.talk.repo" />
<call method="setLogger">
<argument type="service" id="acme.talk.logger"
on-invalid="ignore" />
</call>
</service>
</services>
</container>
55. The state of DI in PHP
Symfony2 – Property Injection
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.talk.repo"
class="AcmeTalkBundleServiceTalkRepository" />
<service id="acme.talk.service"
class="AcmeTalkBundleServiceTalkService">
<property name="talkRepository" type="service"
id="acme.talk.repo" />
</service>
</services>
</container>
56. The state of DI in PHP
Symfony2 – Interface Injection
Not supported!
57. The state of DI in PHP
Symfony2 – private/public Services
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.talk.logger"
class="AcmeTalkBundleServiceLogger" public="false" />
<service id="acme.talk.repo"
class="AcmeTalkBundleServiceTalkRepository" />
<service id="acme.talk.service"
class="AcmeTalkBundleServiceTalkService">
<argument type="service" id="acme.talk.repo" />
<call method="setLogger">
<argument type="service" id="acme.talk.logger" />
</call>
</service>
</services>
</container>
58. The state of DI in PHP
Symfony2 – Service inheritance
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.talk.serviceparent"
class="AcmeTalkBundleServiceTalkService" abstract="true">
<property name="talkRepository" type="service"
id="acme.talk.repo" />
</service>
<service id="acme.talk.service" parent="acme.talk.serviceparent" />
<service id="acme.talk.service2" parent="acme.talk.serviceparent" />
</services>
</container>
59. The state of DI in PHP
Symfony2 – Service scoping
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="acme.talk.repo"
class="AcmeTalkBundleServiceTalkRepository" />
<service id="acme.talk.service"
class="AcmeTalkBundleServiceTalkService" scope="prototype">
<property name="talkRepository" type="service"
id="acme.talk.repo" />
</service>
</services>
</container>
61. The state of DI in PHP
Flow3 – Constructor Injection
<?php
namespace AcmeDemoController;
use TYPO3FLOW3Annotations as FLOW3;
/**
* @FLOW3Scope("session")
*/
class StandardController extends TYPO3FLOW3MVCControllerActionController {
/**
* @var AcmeDemoServiceTalkServiceInterface
*/
protected $talkService;
public function __construct(
AcmeDemoServiceTalkService $talkService) {
$this->talkService = $talkService;
}
public function indexAction() {
}
}
62. The state of DI in PHP
Flow3 – Setter Injection (manually)
<?php
namespace AcmeDemoController;
use TYPO3FLOW3Annotations as FLOW3;
/**
* @FLOW3Scope("session")
*/
class StandardController extends TYPO3FLOW3MVCControllerActionController {
/**
* @var AcmeDemoServiceTalkServiceInterface
*/
protected $talkService;
public function setTalkService(
AcmeDemoServiceTalkService $talkService) {
$this->talkService = $talkService;
}
public function indexAction() {
}
}
63. The state of DI in PHP
Flow3 – Setter Injection (manually)
File Objects.yaml in Packages/Application/Acme.Demo/Configuration
# @package Acme
AcmeDemoControllerStandardController:
properties:
talkService:
object: AcmeDemoServiceTalkService
64. The state of DI in PHP
Flow3 – Setter Injection (Automagic)
<?php
namespace AcmeDemoController;
use TYPO3FLOW3Annotations as FLOW3;
/**
* @FLOW3Scope("session")
*/
class StandardController extends TYPO3FLOW3MVCControllerActionController {
/**
* @var AcmeDemoServiceTalkServiceInterface
*/
protected $talkService;
public function injectTalkService(
AcmeDemoServiceTalkService $talkService) {
$this->talkService = $talkService;
}
public function indexAction() {
}
}
65. The state of DI in PHP
Flow3 – Setter Injection (Automagic)
<?php
namespace AcmeDemoController;
use TYPO3FLOW3Annotations as FLOW3;
/**
* @FLOW3Scope("session")
*/
class StandardController extends TYPO3FLOW3MVCControllerActionController {
/**
* @var AcmeDemoServiceTalkServiceInterface
*/
protected $talkService;
public function injectSomethingElse(
AcmeDemoServiceTalkService $talkService) {
$this->talkService = $talkService;
}
public function indexAction() {
}
}
66. The state of DI in PHP
Flow3 – Property Injection
<?php
namespace AcmeDemoController;
use TYPO3FLOW3Annotations as FLOW3;
/**
* @FLOW3Scope("session")
*/
class StandardController extends TYPO3FLOW3MVCControllerActionController {
/**
* @var AcmeDemoServiceTalkService
* @FLOW3Inject
*/
protected $talkService;
public function indexAction() {
}
}
67. The state of DI in PHP
Flow3 – Property Injection (with Interface)
<?php
namespace AcmeDemoController;
use TYPO3FLOW3Annotations as FLOW3;
/**
* @FLOW3Scope("session")
*/
class StandardController extends TYPO3FLOW3MVCControllerActionController {
/**
* @var AcmeDemoServiceTalkServiceInterface
* @FLOW3Inject
*/
protected $talkService;
public function indexAction() {
}
}
68. The state of DI in PHP
Flow3 – Property Injection (with Interface)
File Objects.yaml in Packages/Application/Acme.Demo/Configuration
# @package Acme
AcmeDemoServiceTalkServiceInterface:
className: 'AcmeDemoServiceTalkService'
69. The state of DI in PHP
Flow3 – Scoping
<?php
namespace AcmeDemoController;
use TYPO3FLOW3Annotations as FLOW3;
/**
* @FLOW3Scope("session")
*/
class StandardController extends TYPO3FLOW3MVCControllerActionController {
/**
* @var AcmeDemoServiceTalkServiceInterface
* @FLOW3Inject
*/
protected $talkService;
public function indexAction() {
}
}