Best kept in a glass cabinet.

Overview

Uranium

Best kept in a glass cabinet.

Do you feel like async is too unwieldy and annoying to type?
Do you wake up every morning with unfulfilled promises?
Do you wish you could stop typing ->then or yield?
Is this you? well then Uranium might be for you!

Thanks to the newly introduced Fibers, Uranium can take all those worries away!

Writing async code has never been easier! want to read a file but asynchronously?
with the simple API of Uranium it's never been so easy!



include __DIR__ . "/../vendor/autoload.php";

use Cijber\Uranium\IO\Filesystem;

$data = Filesystem::slurp("/tmp/big_file");

This isn't asynchronous you may say, but alas, it is. all actual async logic has been hidden away to allow for hybrid usage.

A simple example can be shown that it is with the following script

readLine()) { echo "You said: " . $line; } ">


include __DIR__ . "/../vendor/autoload.php";

use Cijber\Uranium\IO\Stream;
use Cijber\Uranium\Uranium;
use Cijber\Uranium\Timer\Duration;

$stdin = Stream::stdin();

Uranium::interval(Duration::seconds(2), function() {
    echo "Hello fellow async libraries!\n";
});

while ($line = $stdin->readLine()) {
    echo "You said: " . $line;
}

This script will output every 2 seconds "Hello fellow async libraries!", but when you write something and press enter it'll also output "You said: ".

Magic! (bring your own SFX)

What's actually happening under the hood is that when Uranium is told to wait for something, it will check if there's already an event loop running, and if not, start one!

This has its downsides, but allows for building hybrid async/sync libraries with which the user has not to worry about it.

The biggest downside is that after your async function is done, the event loop will stop. thus make sure you clean up!

This can be a nasty downside for actual async apps, thus it's not recommended doing this for full-blown async apps. For these Uranium::app can be used, which will run the event loop until no tasks are left. like so:

lines() as $line) { echo "You said: " . $line; } }); ">



include __DIR__ . "/../vendor/autoload.php";

use Cijber\Uranium\IO\Stream;
use Cijber\Uranium\Timer\Duration;
use Cijber\Uranium\Uranium;


$stdin = Stream::stdin();

Uranium::interval(Duration::seconds(2), function() {
    echo "Hello fellow async libraries!\n";
});

Uranium::app(function (){
    foreach ($stdin->lines() as $line) {
        echo "You said: " . $line;
    }
});

FAQ

Will this work without Fibers?

yes, but poorly. every time it's supposed to wait it just runs the event loop there, thus there's a chance for recursion issues if the stack gets too big (read SEGFAULT's). for a little testing it should work though!

Is this stable?

It'll have a half life of at least 68.9 years.

Is it compatible with ReactPHP or Amphp?

It's not intended to be, but it could be done, do note that Amp and React have very different architectural designs than Uranium.

Will windows be supported?

Not planning to, I am however accepting PR's in that regard.

What event loops will be supported?

Currently, it supports the native stream_select loop.

Instead of supporting all 3 event based php libraries, I am instead looking at just supporting one of the Big Three.

I prefer working closely to what the kernel offers me, so this will most likely be libev. There's also high chance that I make my own epoll based loop with the help of FFI.

You might also like...
The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily
The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily

BroadcastACM The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily. Make the best announcements for your server w

The best profanity filter for chat with api for plugin developers!
The best profanity filter for chat with api for plugin developers!

xqwtxon/ProfanityFilter is moving on ReinfyTeam/ProfanityFilter ProfanityFilter 🤐 A best profanity filter for pocketmine. Controls hate speech and bl

This package implements 0-1 Knapsack Problem algorithm i.e. allows to find the best way to fill a knapsack of a specified volume with items of a certain volume and value.

This package implements "0-1 Knapsack Problem" algorithm i.e. allows to find the best way to fill a knapsack of a specified volume with items of a certain volume and value.

Gamecom.io - Find the best game, community, mod, or servers for you! Data retrieved from @modcommunity.
Gamecom.io - Find the best game, community, mod, or servers for you! Data retrieved from @modcommunity.

A website made by Christian Deacon that helps users find any game, community, mod, or server. All data retrieved by @modcommunity. This website is ope

YCOM Impersonate. Login as selected YCOM user 🧙‍♂️in frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Modern, simple and fresh looking glass based on Bootstrap 5 and PHP 7
Modern, simple and fresh looking glass based on Bootstrap 5 and PHP 7

Modern, simple and fresh looking glass based on Bootstrap 5 and PHP 7. A looking glass is a network utility which is made user-friendly for everyone to use. It allows you to execute network related commands within a remote network, usually that of an ISP.

Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.
Rinvex Authy is a simple wrapper for @Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest API for developers and a strong authentication platform for the enterprise.

Rinvex Authy Rinvex Authy is a simple wrapper for Authy TOTP API, the best rated Two-Factor Authentication service for consumers, simplest 2fa Rest AP

PHP's best friend for the terminal.
PHP's best friend for the terminal.

Running PHP from the command line? CLImate is your new best bud. CLImate allows you to easily output colored text, special formats, and more. Installa

FuelPHP v1.x is a simple, flexible, community driven PHP 5.3+ framework, based on the best ideas of other frameworks, with a fresh start! FuelPHP is fully PHP 7 compatible.

FuelPHP Version: 1.8.2 Website Release Documentation Release API browser Development branch Documentation Development branch API browser Support Forum

A php.ini scanner for best security practices

Scanner for PHP.ini The Iniscan is a tool designed to scan the given php.ini file for common security practices and report back results. Currently it

"結巴"中文分詞:做最好的 PHP 中文分詞、中文斷詞組件。 / "Jieba" (Chinese for "to stutter") Chinese text segmentation: built to be the best PHP Chinese word segmentation module.

jieba-php "結巴"中文分詞:做最好的 PHP 中文分詞、中文斷詞組件,目前翻譯版本為 jieba-0.33 版本,未來再慢慢往上升級,效能也需要再改善,請有興趣的開發者一起加入開發!若想使用 Python 版本請前往 fxsjy/jieba 現在已經可以支援繁體中文!只要將字典切換為 bi

The best php curl library.

中文文档 About Implemented by using php-curl internal io event with high performance,high universality,high extensibility which especially suitable for ma

Bedrock is a modern WordPress stack that helps you get started with the best development tools and project structure.
Bedrock is a modern WordPress stack that helps you get started with the best development tools and project structure.

WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure

An amazing Rank and Permissions Manager. The best ranks manager for PocketMine-MP.

👑 RankSystem 🔧 An amazing Rank and Permissions Manager Description: An amazing Rank and Permissions Manager. The best ranks manager for PocketMine-M

Simple custom chat bot developing framework for telegram, qq and more in PHP (the best language)
Simple custom chat bot developing framework for telegram, qq and more in PHP (the best language)

RinoBot RinoBot 是一个为统一聊天机器人扩展开发的框架,编写一份插件用于多种机器人协议。 简体中文 | English 🚧 开发中 🚧 暂不适用于生产环境 特性 插件扩展机制 一份代码运行于多平台多协议机器人 并减小开发难度 插件提供 Yaml 配置 供使用者修改 基于机器人 We

The best kernel for simple apps

Sunflower Sunflower is a super small application kernel that is used to build a dependency injection container. This kernel is useful for microservice

Laravel best practices
Laravel best practices

Translations: Nederlands (by Protoqol) Indonesia (by P0rguy, Doni Ahmad) 한국어 (by cherrypick) 日本語 (by 2bo) 简体中文 (by xiaoyi) 繁體中文 (by woeichern) ภาษาไทย

The best squirrel tracker. Ever. (A demo app for LaravelSF meetups)

LaraSqrrl Identify and track squirrels via text, now using AWS Rekognition! Created for the November 10th, 2015; February 9th, 2016; May 10th, 2016; a

vimrcfu - Share your best vimrc snippets

vimrcfu http://vimrcfu.com Made with Laravel 4.2 Set up Clone the repository into a directory on your local machine (development) or server (productio

Owner
null
An amazing Rank and Permissions Manager. The best ranks manager for PocketMine-MP.

?? RankSystem ?? An amazing Rank and Permissions Manager Description: An amazing Rank and Permissions Manager. The best ranks manager for PocketMine-M

null 22 Nov 7, 2022
Simple custom chat bot developing framework for telegram, qq and more in PHP (the best language)

RinoBot RinoBot 是一个为统一聊天机器人扩展开发的框架,编写一份插件用于多种机器人协议。 简体中文 | English ?? 开发中 ?? 暂不适用于生产环境 特性 插件扩展机制 一份代码运行于多平台多协议机器人 并减小开发难度 插件提供 Yaml 配置 供使用者修改 基于机器人 We

LixWorth 3 Apr 18, 2022
Learn to apply best practices as a PHP backend developer

PHP eCommerce Project Here are the things that this repo will cover: Object oriented programming principles and best practices Object oriented session

Muhammad Salah 0 Aug 2, 2022
🎓 Collection of useful PHP frequently asked questions, articles and best practices

PHP.earth documentation These files are available online at PHP.earth. Contributing and license We are always looking forward to see your contribution

PHP.earth 278 Dec 27, 2022
A Magento 1.x module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN, Varnish, etc using best practices outlined within the HTML5 boilerplate community.

Magento Cachebuster Cachebuster is a Magento module which facilitates automatic purging of static assets from HTTP caches such as browser cache, CDN,

Gordon Knoppe 129 Apr 1, 2022
Laravel boilerplate with the best development practices.

Laravel Boilerplate Introduction ?? Welcome to Laravel Init - a boilerplate for installing laravel application. It covers: One-liner shell script to s

ColoredCow 7 Dec 29, 2021
Best regular expression for gmail

best regular expression for gmail Gmail Regular expression with all details (not start with dot,number , is it possible to use multiple dot but not in

null 3 Feb 2, 2022
An utility component for XML usage and best practices in PHP

An utility component for XML usage and best practices in PHP

Laminas Project 13 Nov 26, 2022
Your alter ego object. Takes the best of object and array worlds.

Supporting Opensource formapro\values is an MIT-licensed open source project with its ongoing development made possible entirely by the support of com

FormaPro 31 Jun 25, 2021
Enabling community-powered extension and improvements of the best time indications given.

Enabling community-powered extension and improvements of the best time indications given.

Digital Markethingz 2 Jun 29, 2022