SlideShare a Scribd company logo
1 of 23
Download to read offline
Fixin Framework
Attila Jenei
Fixin Framework
• Owner-managed classes
• Flexible
• Simple dispatch flow
• Built for PHP 7.1+
Owner-Managed Classes
• Constructor-based injection via options
__construct($resourceManager, array $options, string $name);
• No public dependency getters and setters
• Responsibility goes to the creator
• Class constants
• Prevents mistyping and hidden not-used options
Managed Class
• Abstract implementation of ManagedInterface
• Supports lazy-loading
• Supports options mapping
• Declares $options processing
Lazy-Loading
• Declaring property
$this->setLazyLoadingProperty(static::ENTITY, EntityInterface::class, $value);
• $value is a key to Resource Manager
• Loading property
protected function getEntity(): EntityInterface

{

return $this->entity ?: $this->loadLazyProperty(static::ENTITY);

}
Options Mapping
protected const THIS_SETS = [

self::DELAY => [Types::INT, Types::NULL],

self::NAME => [self::USING_SETTER, Types::NULL],

self::REPOSITORY => [self::LAZY_LOADING => RepositoryInterface::class]

]
• List of possible options and their allowed types
• Supports lazy-loading
• Supports custom setters
Resource Manager
• Holds shared Resources and preinitialized Prototypes
• Has configuration for the keys
• Supports creation by class name, Factory, and
Abstract Factory
• Request with undefined key interpreted as class name
Resource Manager
• Getting a Resource:
$manager->get(‘BaseJsonJson’, JsonInterface::class);
• Loads options from the configuration on initialization
• Returns a ResourceInterface
• Always returns the same instance for the given key
Resource Manager
• Cloning a Prototype:
$manager->clone(‘BaseJsonJson’, JsonInterface::class, [

JsonInterface::DECODING_MAX_DEPTH => 2

]);
• Loads options from the configuration on
preinitialization
• Returns a cloned instance for the given key with the
additional options
Flexibility
• Interface-based classes
• Resource Manager configuration
• Namespace fallback support
Interfaces
• All classes use interface types
• Option names are defined as interface constants
• All class replaceable with custom implementation
Resouce Manager
Configuration
• Options for the keys
• Option inheritance
• Configuration of ‘B’ key inherited from ‘A’ key
• Aliases
Namespace Fallback
• Referencing without top level
• The root namespace will be determined
• Defined root search order
• Zero configuration for class overriding
• Just put into the right folder
Namespace Fallback
Example:
• Requesting ‘*ViewView’
• Manager looks for ‘AppViewView’
• then: ‘FixinViewView’
Simple Dispatch Flow
• Information Cargo
• Cargo Handlers
• Called Delivery System
Cargo
• Holds the content and its type
• Delivered flag shows final state
• Subtypes has other data too
HTTP Cargo
• Environment, Server
• Cookies, Session
• Protocol Version, Uri, Method
• Request Headers, Parameters
• Status Code, Response Headers
Cargo Handlers
• One required method
public function handle(CargoInterface $cargo): CargoInterface 

{…}
Delivery System
• Application creates a Cargo
• Cargo goes through a Route
• Route builds up from Nodes
• A Hub might send to other handler

(Action Handler, Restful Handler, Route)
• Application unpacks the Cargo
Nodes
• ArrayToJson
• HttpClassHub
• HttpErrorHub
• HttpNotFoundFallback
• HttpRouterHub

• JsonToArray
• ThrowableToText
• ViewRender
• WrapInView
PHP 7.1+
• Parameter type declarations
• Return type declarations
• Nullable types
• Void functions
• Null coalescing operator
• Class constant visibility
Visit https://blog.fixinphp.com
Fixin Framework

More Related Content

What's hot

Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
Clay Helberg
 
YiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's newYiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's new
Alexander Makarov
 

What's hot (8)

13243967
1324396713243967
13243967
 
Helberg acl-final
Helberg acl-finalHelberg acl-final
Helberg acl-final
 
Basics of PHP
Basics of PHPBasics of PHP
Basics of PHP
 
Chelberg ptcuser 2010
Chelberg ptcuser 2010Chelberg ptcuser 2010
Chelberg ptcuser 2010
 
Codeinator
CodeinatorCodeinator
Codeinator
 
Solr Introduction
Solr IntroductionSolr Introduction
Solr Introduction
 
YiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's newYiiConf 2012 - Alexander Makarov - Yii2, what's new
YiiConf 2012 - Alexander Makarov - Yii2, what's new
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 

Similar to Fixin Framework

fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
Kostas Mavridis
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
Erik Hatcher
 

Similar to Fixin Framework (20)

Modularity and Layered Data Model
Modularity and Layered Data ModelModularity and Layered Data Model
Modularity and Layered Data Model
 
The Future of Plugin Dev
The Future of Plugin DevThe Future of Plugin Dev
The Future of Plugin Dev
 
VB.net&OOP.pptx
VB.net&OOP.pptxVB.net&OOP.pptx
VB.net&OOP.pptx
 
springdatajpa-up.pdf
springdatajpa-up.pdfspringdatajpa-up.pdf
springdatajpa-up.pdf
 
Staying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHPStaying Sane with Drupal NEPHP
Staying Sane with Drupal NEPHP
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
CodeIgniter & MVC
CodeIgniter & MVCCodeIgniter & MVC
CodeIgniter & MVC
 
Andrei shakirin rest_cxf
Andrei shakirin rest_cxfAndrei shakirin rest_cxf
Andrei shakirin rest_cxf
 
Calypso underhood
 Calypso underhood Calypso underhood
Calypso underhood
 
fuser interface-development-using-jquery
fuser interface-development-using-jqueryfuser interface-development-using-jquery
fuser interface-development-using-jquery
 
ERRest in Depth
ERRest in DepthERRest in Depth
ERRest in Depth
 
Jpa
JpaJpa
Jpa
 
WordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a FrameworkWordPress Café: Using WordPress as a Framework
WordPress Café: Using WordPress as a Framework
 
ACL in CodeIgniter
ACL in CodeIgniterACL in CodeIgniter
ACL in CodeIgniter
 
Breaking the limits_of_page_objects
Breaking the limits_of_page_objectsBreaking the limits_of_page_objects
Breaking the limits_of_page_objects
 
Lucene for Solr Developers
Lucene for Solr DevelopersLucene for Solr Developers
Lucene for Solr Developers
 
Zend framework: Getting to grips (ZF1)
Zend framework: Getting to grips (ZF1)Zend framework: Getting to grips (ZF1)
Zend framework: Getting to grips (ZF1)
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
 
Octopus framework; Permission based security framework for Java EE
Octopus framework; Permission based security framework for Java EEOctopus framework; Permission based security framework for Java EE
Octopus framework; Permission based security framework for Java EE
 
Extending eZ Platform 2.x with Symfony and React
Extending eZ Platform 2.x with Symfony and ReactExtending eZ Platform 2.x with Symfony and React
Extending eZ Platform 2.x with Symfony and React
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Fixin Framework

  • 2. Fixin Framework • Owner-managed classes • Flexible • Simple dispatch flow • Built for PHP 7.1+
  • 3. Owner-Managed Classes • Constructor-based injection via options __construct($resourceManager, array $options, string $name); • No public dependency getters and setters • Responsibility goes to the creator • Class constants • Prevents mistyping and hidden not-used options
  • 4. Managed Class • Abstract implementation of ManagedInterface • Supports lazy-loading • Supports options mapping • Declares $options processing
  • 5. Lazy-Loading • Declaring property $this->setLazyLoadingProperty(static::ENTITY, EntityInterface::class, $value); • $value is a key to Resource Manager • Loading property protected function getEntity(): EntityInterface
 {
 return $this->entity ?: $this->loadLazyProperty(static::ENTITY);
 }
  • 6. Options Mapping protected const THIS_SETS = [
 self::DELAY => [Types::INT, Types::NULL],
 self::NAME => [self::USING_SETTER, Types::NULL],
 self::REPOSITORY => [self::LAZY_LOADING => RepositoryInterface::class]
 ] • List of possible options and their allowed types • Supports lazy-loading • Supports custom setters
  • 7. Resource Manager • Holds shared Resources and preinitialized Prototypes • Has configuration for the keys • Supports creation by class name, Factory, and Abstract Factory • Request with undefined key interpreted as class name
  • 8. Resource Manager • Getting a Resource: $manager->get(‘BaseJsonJson’, JsonInterface::class); • Loads options from the configuration on initialization • Returns a ResourceInterface • Always returns the same instance for the given key
  • 9. Resource Manager • Cloning a Prototype: $manager->clone(‘BaseJsonJson’, JsonInterface::class, [
 JsonInterface::DECODING_MAX_DEPTH => 2
 ]); • Loads options from the configuration on preinitialization • Returns a cloned instance for the given key with the additional options
  • 10. Flexibility • Interface-based classes • Resource Manager configuration • Namespace fallback support
  • 11. Interfaces • All classes use interface types • Option names are defined as interface constants • All class replaceable with custom implementation
  • 12. Resouce Manager Configuration • Options for the keys • Option inheritance • Configuration of ‘B’ key inherited from ‘A’ key • Aliases
  • 13. Namespace Fallback • Referencing without top level • The root namespace will be determined • Defined root search order • Zero configuration for class overriding • Just put into the right folder
  • 14. Namespace Fallback Example: • Requesting ‘*ViewView’ • Manager looks for ‘AppViewView’ • then: ‘FixinViewView’
  • 15. Simple Dispatch Flow • Information Cargo • Cargo Handlers • Called Delivery System
  • 16. Cargo • Holds the content and its type • Delivered flag shows final state • Subtypes has other data too
  • 17. HTTP Cargo • Environment, Server • Cookies, Session • Protocol Version, Uri, Method • Request Headers, Parameters • Status Code, Response Headers
  • 18. Cargo Handlers • One required method public function handle(CargoInterface $cargo): CargoInterface 
 {…}
  • 19. Delivery System • Application creates a Cargo • Cargo goes through a Route • Route builds up from Nodes • A Hub might send to other handler
 (Action Handler, Restful Handler, Route) • Application unpacks the Cargo
  • 20. Nodes • ArrayToJson • HttpClassHub • HttpErrorHub • HttpNotFoundFallback • HttpRouterHub
 • JsonToArray • ThrowableToText • ViewRender • WrapInView
  • 21. PHP 7.1+ • Parameter type declarations • Return type declarations • Nullable types • Void functions • Null coalescing operator • Class constant visibility