{"id":16288645,"url":"https://github.com/smuuf/primi","last_synced_at":"2025-05-16T07:05:32.886Z","repository":{"id":38419553,"uuid":"107181535","full_name":"smuuf/primi","owner":"smuuf","description":"Primi language: A scripting language written in PHP.","archived":false,"fork":false,"pushed_at":"2024-12-23T01:33:09.000Z","size":1844,"stargazers_count":125,"open_issues_count":2,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-05-14T03:43:17.815Z","etag":null,"topics":["interpreted-programming-language","interpreter","language","php","primi","programming","repl","scripting","scripting-language"],"latest_commit_sha":null,"homepage":"","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/smuuf.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}},"created_at":"2017-10-16T20:49:59.000Z","updated_at":"2025-04-14T14:27:20.000Z","dependencies_parsed_at":"2024-12-22T23:07:34.543Z","dependency_job_id":"1ed34f8e-41bb-4dab-b097-4f2be0decec8","html_url":"https://github.com/smuuf/primi","commit_stats":{"total_commits":632,"total_committers":5,"mean_commits":126.4,"dds":"0.23259493670886078","last_synced_commit":"d66ad6a397080a4caec9b634c925c0e085a00bb0"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smuuf%2Fprimi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smuuf%2Fprimi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smuuf%2Fprimi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smuuf%2Fprimi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smuuf","download_url":"https://codeload.github.com/smuuf/primi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254485060,"owners_count":22078767,"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":["interpreted-programming-language","interpreter","language","php","primi","programming","repl","scripting","scripting-language"],"created_at":"2024-10-10T19:48:57.910Z","updated_at":"2025-05-16T07:05:27.878Z","avatar_url":"https://github.com/smuuf.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://raw.githubusercontent.com/smuuf/primi/master/res/art/logo-sml.png\" alt=\"Primi\"\u003e\n  \u003ch1 align=\"center\"\u003ePrimi\u003c/h1\u003e\n  \u003cp align=\"center\"\u003eA scripting language \u003ci\u003e\u003cb\u003ewritten in PHP\u003c/i\u003e\u003c/b\u003e \u0026 \u003ci\u003e\u003cb\u003einterpreted in PHP\u003c/b\u003e\u003c/i\u003e.\u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  Primi is meant for PHP developers who want to \u003cb\u003eallow their clients to write their own custom logic\u003c/b\u003e. Primi allows you \u003ci\u003e(the developer)\u003c/i\u003e to \u003cb\u003eexecute untrusted code\u003c/b\u003e \u003ci\u003e(provided simply as a string)\u003c/i\u003e inside a sandbox, safely separated from its surroundings.\n\u003c/p\u003e\n\n---\n\nCode Climate | Packagist\n--- | ---\n[![Maintainability](https://api.codeclimate.com/v1/badges/bc3d946e32cc30820cc9/maintainability)](https://codeclimate.com/github/smuuf/primi/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/bc3d946e32cc30820cc9/test_coverage)](https://codeclimate.com/github/smuuf/primi/test_coverage) | [![Latest Stable Version](https://poser.pugx.org/smuuf/primi/v/stable)](https://packagist.org/packages/smuuf/primi) [![License](https://poser.pugx.org/smuuf/primi/license)](https://packagist.org/packages/smuuf/primi) [![Total Downloads](https://poser.pugx.org/smuuf/primi/downloads)](https://packagist.org/packages/smuuf/primi)\n\n---\n\n# Quick access\n- [Language reference (syntax help)](/docs/language_reference.md)\n\n# Rationale\nPrimi *- as things sometimes go in life -* began as an answer to a practical problem: I needed some general-purpose *(ie. not too much domain-specific)* scripting language that my other app's users could use to write their simple custom logic. I needed some universally usable and **primi**tive scripting thing, with familiar syntax *(`PHP-like` x `C-like` x `JS-like`)* and one that could be safely executed inside pure PHP environment *(no external depedencies on v8js, v8 and whatnot - meaning Javascript is out of the game...)*.\n\n***Thus, Primi was (mostly as an experiment) created.***\n\n# Installation\nYou can either use *Primi* as a **[standalone package](#a-standalone-installation)** `(a)` - for its development, making contributions, debugging it, or to just play with it. Or you can use *Primi* **[in your own projects](#b-as-a-library)** `(b)` by installing it as a Composer dependency.\n\n#### You'll want either one of these:\n- `git clone https://github.com/smuuf/primi.git` *(standalone use)*\n- `composer require smuuf/primi` *(using Primi as a library in your own project)*\n\n## a) Standalone installation\n\n1. Clone this repo.\n    - `git clone https://github.com/smuuf/primi.git`\n2. Install Composer dependencies.\n    - `composer install`\n3. Run something with Primi CLI.\n    - `chmod +x ./primi \u0026\u0026 ./primi -s -c \"a = 1 + 2 / 3;\"`\n\n### Convenient installation Oneliner™:\n```\ngit clone https://github.com/smuuf/primi.git \u0026\u0026 cd primi \u0026\u0026 composer install \u0026\u0026 chmod +x ./primi \u0026\u0026 ./primi -s -c \"msg = 'Primi works.';\"\n```\n\n### Extra stuff:\n- **Register Primi's CLI executable** for current user so typing `primi` will behave like a binary *(otherwise you'd need to write `./primi` and would have to be in the right directory)*:\n    ```\n    ./bin/registerbin\n    ```\n\n    *Note: This will add an alias in .bashrc for current user.*\n- **Run tests** *(tests are located inside `./tests/` directory)*:\n    ```\n    ./bin/test\n    ```\n- **Rebuild parser** *(when you modify Primi's grammar definitions, you will want to rebuild the parser to reflect the changes)*:\n    ```\n    ./bin/buildparser\n    ```\n\n\n\n## b) Using Primi as a library\n\n1. First, install [Primi Composer package](https://packagist.org/packages/smuuf/primi): `composer require smuuf/primi`\n2. Then use it like this:\n```php\n\u003c?php\n\nrequire __DIR__ . \"/vendor/autoload.php\";\n\n$context = new \\Smuuf\\Primi\\Context;\n$interpreter = new \\Smuuf\\Primi\\Interpreter($context);\n\ntry {\n\n    // Let the interpreter run a source code.\n    $interpreter-\u003erun('a = 1; b = a + 2; c = \"some string\"; d = c + \" extra thing\";');\n\n    // Get defined variables from primary context and print them.\n    foreach ($context-\u003egetVariables() as $name =\u003e $value) {\n        printf(\"%s (%s) ... %s\\n\", $name, $value::TYPE, $value-\u003egetCoreValue());\n    }\n\n} catch (\\Smuuf\\Primi\\ErrorException $e) {\n    die($e-\u003egetMessage());\n}\n\n```\n\nRunning this code would output:\n\n```\na (number) ... 1\nb (number) ... 3\nc (string) ... some string\nd (string) ... some string extra thing\n\n```\n\n# REPL mode\nPrimi provides a convenient *\"sandbox\"* [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) mode which is launched by executing `./primi` without any argument. You can use this for messing around with the language or to test any new stuff you might be trying to implement *(e.g. your own Primi extensions written in PHP)*.\n\n![REPL example usage](https://raw.githubusercontent.com/smuuf/primi/master/res/repl-sample.gif)\n\nIn this mode, all statements are executed when entered and the result value of the last expression is returned. REPL commands history is preserved between separate sessions *(history is stored in `~/.primi_history` file)*.\n\n# Language reference\nThe basics of the language syntax and data types are found here:\nhttps://github.com/smuuf/primi/blob/master/docs/language_reference.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmuuf%2Fprimi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmuuf%2Fprimi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmuuf%2Fprimi/lists"}