{"id":20140249,"url":"https://github.com/10quality/php-class-to-javascript","last_synced_at":"2025-10-08T06:09:18.590Z","repository":{"id":56937910,"uuid":"82961232","full_name":"10quality/php-class-to-javascript","owner":"10quality","description":"PHP trait that casts (transforms, converts) classes into javascript objects (string version).","archived":false,"fork":false,"pushed_at":"2017-02-28T19:04:10.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"v1.0","last_synced_at":"2025-06-19T08:44:45.449Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/10quality.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}},"created_at":"2017-02-23T19:05:09.000Z","updated_at":"2017-02-23T20:47:59.000Z","dependencies_parsed_at":"2022-08-21T01:10:14.832Z","dependency_job_id":null,"html_url":"https://github.com/10quality/php-class-to-javascript","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/10quality/php-class-to-javascript","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fphp-class-to-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fphp-class-to-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fphp-class-to-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fphp-class-to-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/10quality","download_url":"https://codeload.github.com/10quality/php-class-to-javascript/tar.gz/refs/heads/v1.0","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/10quality%2Fphp-class-to-javascript/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278897836,"owners_count":26064888,"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-08T02:00:06.501Z","response_time":56,"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-13T21:49:53.685Z","updated_at":"2025-10-08T06:09:18.569Z","avatar_url":"https://github.com/10quality.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Class to Javascript (PHP trait)\n\n[![Latest Stable Version](https://poser.pugx.org/10quality/php-class-to-javascript/v/stable)](https://packagist.org/packages/10quality/php-class-to-javascript)\n[![Total Downloads](https://poser.pugx.org/10quality/php-class-to-javascript/downloads)](https://packagist.org/packages/10quality/php-class-to-javascript)\n[![License](https://poser.pugx.org/10quality/php-class-to-javascript/license)](https://packagist.org/packages/10quality/php-class-to-javascript)\n\nPHP trait that casts (transforms, converts) classes into javascript objects (string version).\n\n## Installation\n\nWith composer, make the dependecy required in your project:\n```bash\ncomposer require 10quality/php-class-to-javascript\n```\n\n## Usage\n\nAdd trait to the wanted class:\n```php\nuse TenQuality\\Traits\\CastJavascriptTrait;\n\nclass MyClass\n{\n    use CastJavascriptTrait;\n}\n```\n\nThe user the casting methods:\n```php\n$class = new MyClass;\n$class-\u003etoJS();\n$class-\u003eto_js(); // Alias\n```\n\n### Hide properties\n\nTo hide properties on casting, add the `hidden` property to the class:\n```php\nclass MyClass\n{\n    use CastJavascriptTrait;\n\n    protected $hidden = [\n        'propertyA',\n        'property_2',\n    ];\n}\n```\n\n### Properties selection\n\nTo select a specific selection of properties to cast, add the `castingProperties` property to the class:\n```php\nclass MyClass\n{\n    use CastJavascriptTrait;\n\n    // (1) As array\n    protected $castingProperties = [\n        'propertyA',\n        'property_2',\n    ];\n}\n```\n\n```php\nclass MyClass\n{\n    use CastJavascriptTrait;\n\n    protected $attributes = [\n        'id',\n        'name',\n    ];\n\n    // (1) As property mapping\n    protected $castingProperties = 'attributes';\n}\n```\n\n## Coding guidelines\n\nPSR-4.\n\n## LICENSE\n\nThe MIT License (MIT)\n\nCopyright (c) 2017 [10Quality](http://www.10quality.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10quality%2Fphp-class-to-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F10quality%2Fphp-class-to-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F10quality%2Fphp-class-to-javascript/lists"}