All Projects → nunomaduro → Yorn

nunomaduro / Yorn

Licence: mit
⚗️ Modules in PHP with the `import` and `export` syntax

Labels

Projects that are alternatives of or similar to Yorn

Flow Ui
Flow-UI is a highly customizable UI framework based Seajs/jQuery。
Stars: ✭ 79 (-43.97%)
Mutual labels:  modules
As
VCV Rack Modules
Stars: ✭ 104 (-26.24%)
Mutual labels:  modules
Spring Boot Quick
🌿 基于springboot的快速学习示例,整合自己遇到的开源框架,如:rabbitmq(延迟队列)、Kafka、jpa、redies、oauth2、swagger、jsp、docker、spring-batch、异常处理、日志输出、多模块开发、多环境打包、缓存cache、爬虫、jwt、GraphQL、dubbo、zookeeper和Async等等📌
Stars: ✭ 1,819 (+1190.07%)
Mutual labels:  modules
Godot Lang Support
A community-maintained list of Language Support Projects for Godot Engine.
Stars: ✭ 86 (-39.01%)
Mutual labels:  modules
Async Ray
Provide async/await callbacks for every, find, findIndex, filter, forEach, map, reduce, reduceRight and some methods in Array.
Stars: ✭ 102 (-27.66%)
Mutual labels:  modules
Cjstoesm
A tool that can transform CommonJS to ESM
Stars: ✭ 109 (-22.7%)
Mutual labels:  modules
Modules Papers
A collection of papers on modules.
Stars: ✭ 74 (-47.52%)
Mutual labels:  modules
Decouplingkit
decoupling between modules in your iOS Project. iOS模块化过程中模块间解耦方案
Stars: ✭ 136 (-3.55%)
Mutual labels:  modules
Awesome Awesome Nodejs
🐢🚀 An Awesome list of Awesome lists related to Node.js.
Stars: ✭ 1,389 (+885.11%)
Mutual labels:  modules
Pnpm
Fast, disk space efficient package manager -- 快速的,节省磁盘空间的包管理工具
Stars: ✭ 14,219 (+9984.4%)
Mutual labels:  modules
Maskjs
Markup | Template | HMVC
Stars: ✭ 89 (-36.88%)
Mutual labels:  modules
Java 9 Spring Webflux
Java-9-Spring-Webflux 一书源码
Stars: ✭ 95 (-32.62%)
Mutual labels:  modules
Annotation Processing Example
It is the example project for the annotation processing tutorial.
Stars: ✭ 116 (-17.73%)
Mutual labels:  modules
Hub
Android 开发中通过接口获取实现类,可用于module之间的通信,通过注解解决module的依赖初始化问题,良好的多线程环境下的线程安全以及性能。a concise di library which can get implementation class for a interface easily in multiple module app , also avoid check null when want to invoke a implementation by interface.
Stars: ✭ 79 (-43.97%)
Mutual labels:  modules
Registry
Components as records of functions for Haskell
Stars: ✭ 132 (-6.38%)
Mutual labels:  modules
Postcss Modules Example
How to use postcss-modules plugin
Stars: ✭ 78 (-44.68%)
Mutual labels:  modules
Parcel
The zero configuration build tool for the web. 📦🚀
Stars: ✭ 39,670 (+28034.75%)
Mutual labels:  modules
Kube Aws Iam Controller
Distribute different AWS IAM credentials to different pods in Kubernetes via secrets.
Stars: ✭ 137 (-2.84%)
Mutual labels:  modules
Practical Server Side Swift
Vapor 4 code samples for the Practical Server Side Swift book
Stars: ✭ 133 (-5.67%)
Mutual labels:  modules
Sun
Android-Sun-Framework 模块化开发框架
Stars: ✭ 123 (-12.77%)
Mutual labels:  modules

Yorn Preview

Build Status Total Downloads Latest Version License

Modules in PHP with the `import` and `export` syntax.

Yorn was carefully crafted to introduce the support for modules in PHP with the import and export syntax. It was created by Nuno Maduro.

Before 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.

As example, this is how a typical Yorn application would look like:

# src/math/sum.php:
<?php export(function ($one, $two) {
    return $one + $two;
});

# src/index.php:
<?php

$sum = import('math/sum');

echo $sum(1, 2);

🚀 Quick start

Remember, this is just an experiment. Don't use this in production.

# First, install:
composer require nunomaduro/yorn

✨ Exporting a function

Any function can be exported by using the export function:

# src/validators/zipCodeValidator.php:
<?php export(function (string $value) {
    return strlen($value) === 5;
});

✨ Importing a function

Importing is just about as easy as exporting from a module. Importing an exported declaration is done through using one of the import forms below:

# src/index.php
<?php

$zipCodeValidator = import('validators/zipCodeValidator');

echo $zipCodeValidator(8000);

✨ Default exports

Of course, you may want to import all functions in a module:

# src/index.php
<?php

$validators = import('validators'); // zipCodeValidator is imported also here

$zipCodeValidator = $validators->zipCodeValidator;

echo $zipCodeValidator(8000);

💖 Support the development

Do you like this project? Support it by donating

Yorn is open-sourced software licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].