{"id":20934467,"url":"https://github.com/jaxon-php/jaxon-annotations","last_synced_at":"2025-10-13T08:05:52.614Z","repository":{"id":40398638,"uuid":"481695775","full_name":"jaxon-php/jaxon-annotations","owner":"jaxon-php","description":"Annotations support for the Jaxon library.","archived":false,"fork":false,"pushed_at":"2025-07-22T12:36:14.000Z","size":113,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-13T08:05:50.759Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaxon-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-04-14T17:42:11.000Z","updated_at":"2025-07-22T12:36:18.000Z","dependencies_parsed_at":"2023-01-22T20:31:00.532Z","dependency_job_id":"8fad9e79-7b65-4e4b-a824-93c748f7c916","html_url":"https://github.com/jaxon-php/jaxon-annotations","commit_stats":{"total_commits":46,"total_committers":2,"mean_commits":23.0,"dds":"0.021739130434782594","last_synced_commit":"701fded8755d226a22edaadc876f98479f8f0f43"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/jaxon-php/jaxon-annotations","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-annotations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-annotations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-annotations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-annotations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaxon-php","download_url":"https://codeload.github.com/jaxon-php/jaxon-annotations/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaxon-php%2Fjaxon-annotations/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014286,"owners_count":26085489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T22:09:28.590Z","updated_at":"2025-10-13T08:05:52.587Z","avatar_url":"https://github.com/jaxon-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/jaxon-php/jaxon-annotations/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/jaxon-php/jaxon-annotations/actions)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/jaxon-php/jaxon-annotations/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/jaxon-php/jaxon-annotations/?branch=main)\n[![StyleCI](https://styleci.io/repos/481695775/shield?branch=main)](https://styleci.io/repos/481695775)\n[![codecov](https://codecov.io/gh/jaxon-php/jaxon-annotations/branch/main/graph/badge.svg?token=HERKC60CC1)](https://codecov.io/gh/jaxon-php/jaxon-annotations)\n\n[![Latest Stable Version](https://poser.pugx.org/jaxon-php/jaxon-annotations/v/stable)](https://packagist.org/packages/jaxon-php/jaxon-annotations)\n[![Total Downloads](https://poser.pugx.org/jaxon-php/jaxon-annotations/downloads)](https://packagist.org/packages/jaxon-php/jaxon-annotations)\n[![Latest Unstable Version](https://poser.pugx.org/jaxon-php/jaxon-annotations/v/unstable)](https://packagist.org/packages/jaxon-php/jaxon-annotations)\n[![License](https://poser.pugx.org/jaxon-php/jaxon-annotations/license)](https://packagist.org/packages/jaxon-php/jaxon-annotations)\n\nAnnotations for the Jaxon library\n=================================\n\nThis package provides annotation support for the Jaxon library.\nThe configuration options that are related to Jaxon classes can be set directly in the class files using annotations.\n\nTwo different syntax are allowed for annotations: the default array-like syntax, and an alternative docblock-like syntax,\navailable since version `1.4`.\n\nInstallation\n------------\n\nInstall this package with `composer`.\nIt requires `jaxon-php/jaxon-core` v4 or higher.\n\n```shell\ncomposer require jaxon-php/jaxon-annotations\n```\n\nSet the annotation config option to on.\n\n```php\njaxon()-\u003esetOption('core.annotations.enabled', true);\n```\n\nUsage\n-----\n\nThe following annotations are provided.\n\n### @exclude\n\nIt prevents a method or a class from being exported to javascript.\nIt takes an optional boolean parameter.\n\n```php\n/**\n * @exclude(true)\n */\nclass JaxonExample\n{\n// This class will not be exported to javascript.\n}\n```\n\n```php\nclass JaxonExample\n{\n    /**\n     * @exclude\n     */\n    public function doNot()\n    {\n        // This method will not be exported to javascript.\n    }\n}\n```\n\nThe PHP-DOC syntax can also be used.\n\n```php\nclass JaxonExample\n{\n    /**\n     * @exclude false\n     */\n    public function do()\n    {\n        // This method will be exported to javascript.\n    }\n\n    /**\n     * @exclude true\n     */\n    public function doNot()\n    {\n        // This method will not be exported to javascript.\n    }\n}\n```\n\n### @upload\n\nIt adds file upload to an ajax request.\nIt takes the id of the HTML field as a mandatory option.\nIt applies only to methods.\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @upload('field' =\u003e 'div-user-file')\n     */\n    public function saveFile()\n    {\n        // Get the uploaded files.\n        $files = $this-\u003eupload()-\u003efiles();\n    }\n}\n```\n\nThe PHP-DOC syntax can also be used.\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @upload div-user-file\n     */\n    public function saveFile()\n    {\n        // Get the uploaded files.\n        $files = $this-\u003eupload()-\u003efiles();\n    }\n}\n```\n\n### @before\n\nIt defines a method of the class as a callback to be called before processing the request.\nIt takes the name of the method as a mandatory parameter, and an array as optional parameters to be passed to the callback.\nIt applies to methods and classes.\n\n```php\nclass JaxonExample\n{\n    protected function funcBefore1()\n    {\n        // Do something\n    }\n\n    protected function funcBefore2($param1, $param2)\n    {\n        // Do something with parameters\n    }\n\n    /**\n     * @before('call' =\u003e 'funcBefore1')\n     * @before('call' =\u003e 'funcBefore2', 'with' =\u003e ['value1', 'value2'])\n     */\n    public function action()\n    {\n    }\n}\n```\n\nThe PHP-DOC syntax can also be used.\n\n```php\nclass JaxonExample\n{\n    protected function funcBefore1()\n    {\n        // Do something\n    }\n\n    protected function funcBefore2($param1, $param2)\n    {\n        // Do something with parameters\n    }\n\n    /**\n     * @before funcBefore1\n     * @before funcBefore2 [\"value1\", \"value2\"]\n     */\n    public function action()\n    {\n    }\n}\n```\n\n### @after\n\nIt defines a method of the class as a callback to be called after processing the request.\nIt takes the name of the method as a mandatory parameter, and an array as optional parameters to be passed to the callback.\nIt applies to methods and classes.\n\n```php\nclass JaxonExample\n{\n    protected function funcAfter1()\n    {\n        // Do something\n    }\n\n    protected function funcAfter2($param)\n    {\n        // Do something with parameter\n    }\n\n    /**\n     * @after('call' =\u003e 'funcAfter1')\n     * @after('call' =\u003e 'funcAfter2', 'with' =\u003e ['value'])\n     */\n    public function action()\n    {\n    }\n}\n```\n\nThe PHP-DOC syntax can also be used.\n\n```php\nclass JaxonExample\n{\n    protected function funcAfter1()\n    {\n        // Do something\n    }\n\n    protected function funcAfter2($param)\n    {\n        // Do something with parameter\n    }\n\n    /**\n     * @after funcAfter1\n     * @after funcAfter2 [\"value\"]\n     */\n    public function action()\n    {\n    }\n}\n```\n\n### @callback\n\nIt defines a javascript object to be used as callback when processing the ajax request.\n\nIt was added in version 2.2.0.\n\n```php\n/**\n * Default callback for all the requests to the class.\n *\n * @callback('name' =\u003e 'jaxon.ajax.callback.example')\n */\nclass JaxonExample\n{\n    /**\n     * Specific callback for this method. It replaces the default class callback.\n     *\n     * @callback('name' =\u003e 'jaxon.ajax.callback.action')\n     */\n    public function action()\n    {\n    }\n}\n```\n\nThe PHP-DOC syntax can also be used.\n\n```php\n/**\n * Default callback for all the requests to the class.\n *\n * @callback jaxon.ajax.callback.example\n */\nclass JaxonExample\n{\n    /**\n     * Specific callback for this method. It replaces the default class callback.\n     *\n     * @callback jaxon.ajax.callback.action\n     */\n    public function action()\n    {\n    }\n}\n```\n\n### @databag\n\nIt defines a data bag to be appended to ajax requests to a method.\nIt takes the name of the data bag as a mandatory parameter.\nIt applies to methods and classes.\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @databag('name' =\u003e 'user')\n     */\n    public function action()\n    {\n        // Update a value in the data bag.\n        $count = $this-\u003ebag('user')-\u003eget('count', 0);\n        $this-\u003ebag('user')-\u003eset('count', $count++);\n    }\n}\n```\n\nThe PHP-DOC syntax can also be used.\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @databag user\n     */\n    public function action()\n    {\n        // Update a value in the data bag.\n        $count = $this-\u003ebag('user')-\u003eget('count', 0);\n        $this-\u003ebag('user')-\u003eset('count', $count++);\n    }\n}\n```\n\n### @di\n\nIt defines an attribute that will be injected in a class.\n\nWhen applied on methods and classes, it takes the name and the class of the attribute as parameters.\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @var \\App\\Services\\Translator\n     */\n     protected $translator;\n\n    /**\n     * @di('attr' =\u003e 'translator', class =\u003e '\\App\\Services\\Translator')\n     */\n    public function translate(string $phrase)\n    {\n        // The $translator property is set from the DI container when this method is called.\n        $phrase = $this-\u003etranslator-\u003etranslate($phrase);\n    }\n}\n```\n\nThe class parameter is optional, and can be omitted if it is already specified by a `@var` annotation.\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @var \\App\\Services\\Translator\n     */\n     protected $translator;\n\n    /**\n     * @di('attr' =\u003e 'translator')\n     */\n    public function translate(string $phrase)\n    {\n        // The $translator property is set from the DI container when this method is called.\n        $phrase = $this-\u003etranslator-\u003etranslate($phrase);\n    }\n}\n```\n\nWhen applied on attributes, it takes the class of the attribute as only parameter, which can be omitted if it is already specified by a `@var` annotation.\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @di(class =\u003e '\\App\\Services\\Translator')\n     * @var \\App\\Services\\Translator\n     */\n     protected $translator;\n\n    public function translate(string $phrase)\n    {\n        // The $translator property is set from the DI container when this method is called.\n        $phrase = $this-\u003etranslator-\u003etranslate($phrase);\n    }\n}\n```\n\n```php\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @di\n     * @var \\App\\Services\\Translator\n     */\n     protected $translator;\n\n    public function translate(string $phrase)\n    {\n        // The $translator property is set from the DI container when this method is called.\n        $phrase = $this-\u003etranslator-\u003etranslate($phrase);\n    }\n}\n```\n\nIf the class name does not start with a `\"\\\"`, then the corresponding fully qualified name (FQN) will be set using\neither the `use` instructions or the `namespace` in its source file.\n\n```php\nnamespace App\\Ajax;\n\nuse App\\Services\\Translator;\n\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @var Translator\n     */\n     protected $translator;\n\n    /**\n     * @var Formatter\n     */\n     protected $formatter;\n\n    /**\n     * @di('attr' =\u003e 'translator', class =\u003e 'Translator')\n     * @di('attr' =\u003e 'formatter', class =\u003e 'Formatter')\n     */\n    public function translate(string $phrase)\n    {\n        // The Translator FQN is defined by the use instruction =\u003e App\\Services\\Translator.\n        // The Formatter FQN is defined by the current namespace =\u003e App\\Ajax\\Formatter.\n        $phrase = $this-\u003eformatter-\u003eformat($this-\u003etranslator-\u003etranslate($phrase));\n    }\n}\n```\n\nThe PHP-DOC syntax can also be used.\n\n```php\nnamespace App\\Ajax;\n\nuse App\\Services\\Translator;\n\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @var Translator\n     */\n     protected $translator;\n\n    /**\n     * @var Formatter\n     */\n     protected $formatter;\n\n    /**\n     * @di $translator   Translator\n     * @di $formatter    Formatter\n     */\n    public function translate(string $phrase)\n    {\n        // The Translator FQN is defined by the use instruction =\u003e App\\Services\\Translator.\n        // The Formatter FQN is defined by the current namespace =\u003e App\\Ajax\\Formatter.\n        $phrase = $this-\u003eformatter-\u003eformat($this-\u003etranslator-\u003etranslate($phrase));\n    }\n}\n```\n\n```php\nnamespace App\\Ajax;\n\nuse App\\Services\\Translator;\n\n/**\n * @di $translator   Translator\n * @di $formatter    Formatter\n */\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @var Translator\n     */\n     protected $translator;\n\n    /**\n     * @var Formatter\n     */\n     protected $formatter;\n\n    public function translate(string $phrase)\n    {\n        // The Translator FQN is defined by the use instruction =\u003e App\\Services\\Translator.\n        // The Formatter FQN is defined by the current namespace =\u003e App\\Ajax\\Formatter.\n        $phrase = $this-\u003eformatter-\u003eformat($this-\u003etranslator-\u003etranslate($phrase));\n    }\n}\n```\n\n```php\nnamespace App\\Ajax;\n\nuse App\\Services\\Translator;\n\nclass JaxonExample extends \\Jaxon\\App\\CallableClass\n{\n    /**\n     * @di  Translator\n     * @var Translator\n     */\n     protected $translator;\n\n    /**\n     * @di  Formatter\n     * @var Formatter\n     */\n     protected $formatter;\n\n    public function translate(string $phrase)\n    {\n        // The Translator FQN is defined by the use instruction =\u003e App\\Services\\Translator.\n        // The Formatter FQN is defined by the current namespace =\u003e App\\Ajax\\Formatter.\n        $phrase = $this-\u003eformatter-\u003eformat($this-\u003etranslator-\u003etranslate($phrase));\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxon-php%2Fjaxon-annotations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaxon-php%2Fjaxon-annotations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaxon-php%2Fjaxon-annotations/lists"}