Phalcon PHP Framework Documentation Versión 1.2.0

Phalcon PHP Framework Documentation Versión 1.2.0

Phalcon PHP Framework Documentation Versión 1.2.0 Phalcon Team 03 de mayo de 2017 Índice general 1. ¿Qué es Phalcon? 3 2. Table of Contents 5 2.1. Nuestra motivación............................................5 2.1.1. La pregunta...........................................5 2.1.2. ¿Porqué?............................................5 2.1.3. ¿Cómo funciona PHP?.....................................6 2.1.4. ¿Cómo trabajan los frameworks tradicionales para PHP?...................6 2.1.5. ¿Cómo trabaja una extensión en C para PHP?.........................6 2.1.6. ¿Cómo trabaja Phalcon?....................................6 2.1.7. Conclusión...........................................6 2.2. Framework Benchmarks.........................................6 2.2.1. ¿Cuál es el entorno de pruebas?................................7 2.2.2. Lista de Benchmarks......................................7 2.2.3. ChangeLog........................................... 22 2.3. Instalación................................................ 22 2.3.1. Windows............................................ 22 2.3.2. Linux/Solaris/Mac....................................... 30 2.3.3. FreeBSD............................................ 31 2.3.4. Notas para la instalación.................................... 31 2.4. Tutorial 1: Aprendamos usando ejemplos................................ 40 2.4.1. Revisando tu instalación.................................... 40 2.4.2. Creando un proyecto...................................... 41 2.4.3. Conclusión........................................... 50 2.4.4. Aplicaciones de Ejemplo.................................... 51 2.5. Tutorial 2: Explicando INVO...................................... 51 2.5.1. Estructura del Proyecto..................................... 51 2.5.2. Enrutamiento.......................................... 52 2.5.3. Configuración.......................................... 52 2.5.4. Autocargadores......................................... 53 2.5.5. Atendiendo la petición..................................... 53 2.5.6. Inyección de Dependencias................................... 53 2.5.7. Iniciar sesión en la Aplicación................................. 54 2.5.8. Asegurando el Backend..................................... 56 2.5.9. Componentes de Usuario.................................... 60 2.5.10. Trabajando con CRUDs..................................... 62 I 2.5.11. Changing the Title Dynamically................................ 67 2.5.12. Conclusion........................................... 68 2.6. Tutorial 3: Creating a Simple REST API................................ 68 2.6.1. Defining the API........................................ 68 2.6.2. Creating the Application.................................... 69 2.6.3. Creating a Model........................................ 70 2.6.4. Retrieving Data......................................... 71 2.6.5. Inserting Data.......................................... 73 2.6.6. Updating Data.......................................... 73 2.6.7. Deleting Data.......................................... 74 2.6.8. Testing our Application..................................... 75 2.6.9. Conclusion........................................... 76 2.7. Inyección de Dependencias/Localización de Servicios......................... 77 2.7.1. Our approach.......................................... 83 2.7.2. Registrar servicios en el contenedor.............................. 83 2.7.3. Resolver Servicios....................................... 89 2.7.4. Servicios Compartidos..................................... 89 2.7.5. Manipular servicios individualmente.............................. 90 2.7.6. Instanciar clases via el contenedor de servicios........................ 90 2.7.7. Automatic Injecting of the DI itself............................... 91 2.7.8. Avoiding service resolution................................... 92 2.7.9. Organizing services in files................................... 92 2.7.10. Accessing the DI in a static way................................ 92 2.7.11. Factory Default DI....................................... 93 2.7.12. Service Name Conventions................................... 93 2.7.13. Implementing your own DI................................... 94 2.8. The MVC Architecture.......................................... 94 2.8.1. Models............................................. 94 2.8.2. Views.............................................. 94 2.8.3. Controllers........................................... 94 2.9. Using Controllers............................................. 94 2.9.1. Dispatch Loop......................................... 96 2.9.2. Initializing Controllers..................................... 97 2.9.3. Injecting Services........................................ 97 2.9.4. Request and Response..................................... 98 2.9.5. Session Data.......................................... 99 2.9.6. Using Services as Controllers.................................. 99 2.9.7. Creating a Base Controller................................... 100 2.9.8. Events in Controllers...................................... 100 2.10. Working with Models.......................................... 101 2.10.1. Creating Models........................................ 101 2.10.2. Models in Namespaces..................................... 102 2.10.3. Understanding Records To Objects............................... 102 2.10.4. Finding Records......................................... 103 2.10.5. Relationships between Models................................. 108 2.10.6. Generating Calculations.................................... 116 2.10.7. Hydration Modes........................................ 118 2.10.8. Creating Updating/Records................................... 119 2.10.9. Skipping Columns....................................... 129 2.10.10. Deleting Records........................................ 131 2.10.11. Validation Failed Events.................................... 132 2.10.12. Behaviors............................................ 132 2.10.13. Transactions........................................... 136 2.10.14. Independent Column Mapping................................. 140 II 2.10.15. Operations over Resultsets................................... 141 2.10.16. Record Snapshots........................................ 142 2.10.17. Models Meta-Data....................................... 143 2.10.18. Pointing to a different schema................................. 147 2.10.19. Setting multiple databases................................... 147 2.10.20. Logging Low-Level SQL Statements.............................. 149 2.10.21. Profiling SQL Statements.................................... 150 2.10.22. Injecting services into Models................................. 151 2.10.23. Disabling/Enabling Features.................................. 151 2.10.24. Stand-Alone component.................................... 152 2.11. Phalcon Query Language (PHQL).................................... 152 2.11.1. Usage Example......................................... 153 2.11.2. Creating PHQL Queries.................................... 154 2.11.3. Selecting Records........................................ 155 2.11.4. Inserting Data.......................................... 159 2.11.5. Updating Data.......................................... 160 2.11.6. Deleting Data.......................................... 161 2.11.7. Creating queries using the Query Builder........................... 162 2.11.8. Escaping Reserved Words................................... 164 2.11.9. PHQL Lifecycle......................................... 164 2.11.10. Using Raw SQL......................................... 164 2.11.11. Troubleshooting......................................... 165 2.12. Caching in the ORM........................................... 165 2.12.1. Caching Resultsets....................................... 166 2.12.2. Overriding find/findFirst.................................... 167 2.12.3. Forcing Cache.......................................... 170 2.12.4. Caching PHQL Queries..................................... 171 2.12.5. Reusable Related Records................................... 171 2.12.6. Caching Related Records.................................... 173 2.12.7. Caching Related Records Recursively............................. 173 2.12.8. Caching based on Conditions.................................. 175 2.13. ODM (Object-Document Mapper).................................... 179 2.13.1. Creating Models........................................ 179 2.13.2. Understanding Documents To Objects............................. 180 2.13.3. Models in Namespaces..................................... 180 2.13.4. Setting a Connection...................................... 181 2.13.5. Finding Documents....................................... 181 2.13.6. Aggregations.......................................... 183 2.13.7. Creating Updating/Records................................... 183 2.13.8. Deleting Records........................................ 188 2.13.9. Validation Failed Events.................................... 189 2.13.10. Implicit Ids vs. User Primary Keys............................... 189 2.13.11. Setting multiple databases................................... 189 2.13.12. Injecting services into Models................................. 190 2.14. Using Views............................................... 191 2.14.1. Integrating Views with Controllers............................... 191 2.14.2. Using Templates........................................ 193

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    723 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us