{"id":13828181,"url":"https://github.com/nunomaduro/yorn","last_synced_at":"2025-04-13T15:53:11.402Z","repository":{"id":57029349,"uuid":"205475601","full_name":"nunomaduro/yorn","owner":"nunomaduro","description":"⚗️ Modules in PHP with the `import` and `export` syntax","archived":false,"fork":false,"pushed_at":"2021-11-21T18:23:18.000Z","size":2541,"stargazers_count":144,"open_issues_count":2,"forks_count":6,"subscribers_count":5,"default_branch":"feat/first","last_synced_at":"2025-03-27T06:44:58.388Z","etag":null,"topics":["modules","php"],"latest_commit_sha":null,"homepage":"https://nunomaduro.com","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/nunomaduro.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"nunomaduro","patreon":"nunomaduro","custom":"https://www.paypal.com/paypalme/enunomaduro"}},"created_at":"2019-08-31T00:45:40.000Z","updated_at":"2024-10-28T13:47:38.000Z","dependencies_parsed_at":"2022-08-23T17:41:04.460Z","dependency_job_id":null,"html_url":"https://github.com/nunomaduro/yorn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fyorn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fyorn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fyorn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nunomaduro%2Fyorn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nunomaduro","download_url":"https://codeload.github.com/nunomaduro/yorn/tar.gz/refs/heads/feat/first","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248741153,"owners_count":21154249,"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","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":["modules","php"],"created_at":"2024-08-04T09:02:35.561Z","updated_at":"2025-04-13T15:53:11.380Z","avatar_url":"https://github.com/nunomaduro.png","language":"PHP","funding_links":["https://github.com/sponsors/nunomaduro","https://patreon.com/nunomaduro","https://www.paypal.com/paypalme/enunomaduro","https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=66BYDWAT92N6L","https://www.patreon.com/nunomaduro"],"categories":["PHP"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/nunomaduro/yorn/feat/first/docs/banner.png\" width=\"900\" alt=\"Yorn Preview\"\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ca href=\"https://travis-ci.org/nunomaduro/yorn\"\u003e\u003cimg src=\"https://img.shields.io/travis/nunomaduro/yorn/master.svg\" alt=\"Build Status\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/nunomaduro/yorn\"\u003e\u003cimg src=\"https://poser.pugx.org/nunomaduro/yorn/d/total.svg\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/nunomaduro/yorn\"\u003e\u003cimg src=\"https://poser.pugx.org/nunomaduro/yorn/v/stable.svg\" alt=\"Latest Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/nunomaduro/yorn\"\u003e\u003cimg src=\"https://poser.pugx.org/nunomaduro/yorn/license.svg\" alt=\"License\"\u003e\u003c/a\u003e\n  \u003c/p\u003e\n  \u003cp align=\"center\"\u003e\n    \u003cstrong\u003eModules in PHP with the `import` and `export` syntax.\u003c/strong\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n**Yorn** was carefully crafted to introduce the support for modules in **PHP** with the `import` and `export` syntax. It was created by **[Nuno Maduro](https://github.com/nunomaduro)**.\n\nBefore the quick start, keep in mind that a module usually contains a collection of functions, and those functions are small units of independent, reusable code that is desired to be used as the building blocks in creating a PHP application.\n\nAs example, this is how a typical **Yorn** application would look like:\n```php\n# src/math/sum.php:\n\u003c?php export(function ($one, $two) {\n    return $one + $two;\n});\n\n# src/index.php:\n\u003c?php\n\n$sum = import('math/sum');\n\necho $sum(1, 2);\n```\n\n## 🚀 Quick start\n\n\u003e Remember, this is just an experiment. Don't use this in production.\n\n```\n# First, install:\ncomposer require nunomaduro/yorn\n```\n\n## ✨ Exporting a function\n\nAny function can be exported by using the `export` function:\n```php\n# src/validators/zipCodeValidator.php:\n\u003c?php export(function (string $value) {\n    return strlen($value) === 5;\n});\n```\n\n## ✨ Importing a function\n\nImporting is just about as easy as exporting from a module. Importing an exported declaration is done through using one of the `import` forms below:\n```php\n# src/index.php\n\u003c?php\n\n$zipCodeValidator = import('validators/zipCodeValidator');\n\necho $zipCodeValidator(8000);\n```\n\n## ✨ Default exports\n\nOf course, you may want to import all functions in a `module`:\n```php\n# src/index.php\n\u003c?php\n\n$validators = import('validators'); // zipCodeValidator is imported also here\n\n$zipCodeValidator = $validators-\u003ezipCodeValidator;\n\necho $zipCodeValidator(8000);\n```\n\n## 💖 Support the development\n**Do you like this project? Support it by donating**\n\n- PayPal: [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=66BYDWAT92N6L)\n- Patreon: [Donate](https://www.patreon.com/nunomaduro)\n\nYorn is open-sourced software licensed under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunomaduro%2Fyorn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnunomaduro%2Fyorn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnunomaduro%2Fyorn/lists"}