Phalcon C Extension Documentation

repository·master·Indexed 27 days ago

https://github.com/phalcon/cphalcon

Phalcon is an open-source web framework delivered as a compiled C extension for PHP to provide high performance and low resource consumption. This documentation covers installation via PIE or PECL, API generation, and detailed feature updates including the Phalcon\Queue component, PDO auto-reconnect support, persistent ACL storage via Phalcon\Acl\Adapter\Storage, and granular exception handling in Phalcon\Auth.

Tokens
36.1K
Snippets
23
Records
398
Agent score
94%

What's inside Phalcon

  1. Use the new Session Manager for session manipulation

    master

    The Phalcon\Session namespace has been refactored. Session manipulation is now handled by a single component: Phalcon\Session\Manager. This manager uses adapters that implement PHP's SessionHandlerInterface.

    Available adapters include:

    • Phalcon\Session\Adapter\Files
    • Phalcon\Session\Adapter\Libmemcached
    • Phalcon\Session\Adapter\Noop
    • Phalcon\Session\Adapter\Redis

    Note: Phalcon\Di\FactoryDefault no longer loads Phalcon\Session\Adapter\Files (as session) or Phalcon\Session\Bag (as sessionBag) by default.

  2. Check PHP version compatibility

    master

    Phalcon version requirements have evolved:

    • v5.5.0+: Minimal support shifted from PHP 7.4 to PHP 8.0. This version also added support for PHP 8.3.
    • v5.6.2+: Includes fixes for PHP 8.2 deprecation warnings (e.g., Phalcon\Di\AbstractInjectionAware now extends stdClass).
  3. Load Forms from Schema using Array, JSON, or YAML

    master

    Phalcon provides several Schema implementations to feed Phalcon\Forms\Form::load(), allowing you to define forms in data formats rather than pure PHP code:

    • Phalcon\Forms\Loader\ArrayLoader: Loads from a PHP array.
    • Phalcon\Forms\Loader\JsonLoader: Loads from a JSON string or file.
    • Phalcon\Forms\Loader\YamlLoader: Loads from a YAML string or file (requires pecl/yaml).

    These loaders work in conjunction with Phalcon\Forms\FormsLocator to resolve element types.

  4. Migration: Changes to Phalcon\Cli\Console module handling

    master

    In Phalcon v5.14.2, Phalcon\Cli\Console::handle() was updated to match the module resolution behavior of Phalcon\Mvc\Application::handle().

    Key Changes:

    • Modules are now resolved through the inherited getModule().
    • New Exception: An unregistered module now throws Phalcon\Application\Exceptions\ModuleNotRegistered (replacing Phalcon\Cli\Console\Exceptions\ConsoleModuleNotRegistered).
    • New Exception: A module definition that is neither an array nor a Closure now throws Phalcon\Cli\Console\Exceptions\InvalidModuleDefinition (replacing InvalidModuleDefinitionPath).
    • Support: Closure module definitions are now supported and are invoked with the container.
  5. Configure Form Rendering with TagFactory in Phalcon v5.0.0

    master

    Starting with version 5.0.0, Phalcon\Forms\Form requires a Phalcon\Html\TagFactory to be set before it can render elements.

    If you are using Phalcon\Di\FactoryDefault, the tag service will automatically return a Phalcon\Html\TagFactory instance.

  6. Update Autoloading methods in Phalcon v5.0.0

    master

    In Phalcon v5.0.0, the Phalcon\Autoload\Loader class has renamed its registration methods to follow a set naming convention. Update your loader configuration as follows:

    • registerClasses() $\rightarrow$ setClasses()
    • registerDirectories() $\rightarrow$ setDirectories()
    • registerExtensions() $\rightarrow$ setExtensions()
    • registerFiles() $\rightarrow$ setFiles()
    • registerNamespaces() $\rightarrow$ setNamespaces()
  7. Migrate ACL terminology from Subject/Operation to Component/Role

    master

    In version 4.0.0-alpha.3, the Access Control List (ACL) component underwent a significant renaming to better reflect its purpose. If you are upgrading to or using version 4.0.0-alpha.3 or later, update your code to use the following mappings:

    Old NameNew Name
    Phalcon\Acl\SubjectPhalcon\Acl\Component
    Phalcon\Acl\SubjectInterfacePhalcon\Acl\ComponentInterface
    Phalcon\Acl\SubjectAwarePhalcon\Acl\ComponentAware
    Phalcon\Acl\OperationPhalcon\Acl\Role
    Phalcon\Acl\OperationInterfacePhalcon\Acl\RoleInterface
    Phalcon\Acl\OperationAwarePhalcon\Acl\RoleAware

    Adapter Method Renames:

    • addOperation $\rightarrow$ addRole
    • isOperation $\rightarrow$ isRole
    • isSubject $\rightarrow$ isComponent
    • addSubject $\rightarrow$ addComponent
    • addSubjectAccess $\rightarrow$ addComponentAccess
    • dropSubjectAccess $\rightarrow$ dropComponentAccess
    • getActiveOperation $\rightarrow$ getActiveRole
    • getActiveSubject $\rightarrow$ getActiveComponent
    • getOperations $\rightarrow$ getRoles
    • getSubjects $\rightarrow$ getComponents
  8. Use verbatim tag in Volt

    master

    To emit a block of code exactly as written without parsing it through the Volt engine, use the {% verbatim %} and {% endverbatim %} tags. This is useful for passing through {{ ... }}, {% ... %}, or client-side templates like Handlebars, Mustache, or Angular untouched.

    Note: The previously used {% raw %} tag was removed and should not be used.

    {% verbatim %}
    ...
    {% endverbatim %}
  9. Generate Phalcon API Documentation

    master

    To generate new API documentation files from the repository, use the provided PHP script. This is useful for maintaining the documentation for specific tags or versions.

    Steps:

    1. Clone the phalcon repository.
    2. Checkout the specific tag you want to document.
    3. Run the generation script.
    4. The resulting *.md files contain the documentation.

    Note: For publishing to the official Phalcon website, the documentation is managed in a separate repository.

    php bin/generate-api-docs.php