{"id":25284736,"url":"https://github.com/omaralalwi/laravel-py","last_synced_at":"2025-09-01T06:41:10.745Z","repository":{"id":276369521,"uuid":"929089348","full_name":"omaralalwi/laravel-py","owner":"omaralalwi","description":"interact with python in Laravel applications .","archived":false,"fork":false,"pushed_at":"2025-03-02T13:39:14.000Z","size":25,"stargazers_count":43,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T16:02:56.181Z","etag":null,"topics":["deepseek-r1","laravel","laravel-python","laravelapi","laravelintegration","laravelpy","laravelpython","php-py","phppy","python-in-php","python-laravel","python-with-laravel"],"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/omaralalwi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2025-02-07T19:37:16.000Z","updated_at":"2025-03-11T19:26:36.000Z","dependencies_parsed_at":"2025-02-08T01:19:26.438Z","dependency_job_id":"fe674b57-4655-4ee3-8096-8a6388927d9c","html_url":"https://github.com/omaralalwi/laravel-py","commit_stats":null,"previous_names":["omaralalwi/laravel-php-py","omaralalwi/laravel-py"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Flaravel-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Flaravel-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Flaravel-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omaralalwi%2Flaravel-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omaralalwi","download_url":"https://codeload.github.com/omaralalwi/laravel-py/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247500470,"owners_count":20948880,"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":["deepseek-r1","laravel","laravel-python","laravelapi","laravelintegration","laravelpy","laravelpython","php-py","phppy","python-in-php","python-laravel","python-with-laravel"],"created_at":"2025-02-12T20:52:23.938Z","updated_at":"2025-04-06T15:13:59.796Z","avatar_url":"https://github.com/omaralalwi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Py - Laravel Python 🚀🐍\n\nLaravel wrapper for **[php-py package](https://github.com/omaralalwi/php-py)** package, to Seamless enabling secure and efficient execution of Python scripts within Laravel applications without spread multiple applications and or setup  API.\n\n## 📌 Table of Contents\n\n- [🔧 Requirements](#requirements)\n- [🚀 Installation](#installation-)\n- [🚀 Quick Start](#-quick-start)\n- [✨ Features](#-features)\n- [📋 Changelog](#-changelog)\n- [🧪 Testing](#-testing)\n- [🔒 Security](#-security)\n- [🤝 Contributors](#-contributors)\n- [📄 License](#-license)\n\n\n---\n\n## Requirements\n\n- PHP 8.1+ .\n- [python3](https://www.python.org/) must be installed in server .\n\n## Installation 🛠️\n\nYou can install the package via Composer:\n\n```bash\ncomposer require omaralalwi/laravel-py\n```\n\n## Publishing Configuration File\n\n```bash\nphp artisan vendor:publish --tag=laravel-py\n```\n\n---\n\n## 🚀 Quick Start\n\n1. 📂 Create a folder for scripts, e.g., `phpPyScripts` in your project root directory.\n2. 📝 Create a Python script file (`.py` extension) and write Python code. [See this script examples](https://github.com/omaralalwi/php-py/tree/master/example-scripts).\n3. 🔧 make script file executable, `chmod +x script_file_path` .\n\n### ⚡ Easy Usage\n\n```php\n\u003c?php\n\nuse LaravelPy;\n\nclass LaravelPyController\n{\n  public function testLaravelPy() {\n      $laravelPy = app(LaravelPy::class);\n      $script = 'total_calculator.py';\n      $arguments = [10, 20, 30];\n          \n      try {\n           $result = $laravelPy\n              -\u003eloadScript($script)\n              -\u003ewithArguments($arguments)\n              -\u003erun();\n              \n          print_r($result); // 60.0\n      } catch (Exception $e) {\n          echo \"Error: \" . $e-\u003egetMessage();\n      }\n  }\n}\n```\n\n### 🔥 Advanced Usage\n\n```php\n\u003c?php\n\nuse LaravelPy;\nuse Omaralalwi\\PhpPy\\Managers\\ConfigManager;\n\nclass LaravelPyController\n{\n  public function testLaravelPy() \n  {\n     try {\n        $laravelPy = app(LaravelPy::class);\n        $script = 'advance_example.py';\n\n        $numbers = [2,4, 5,7,9];\n\n        $config = new ConfigManager([\n            'scripts_directory' =\u003e 'phpPyScripts',\n            'python_executable' =\u003e '/usr/bin/python3',\n            'max_timeout' =\u003e 120,\n        ]);\n\n        $result = $laravelPy\n            -\u003esetConfig($config)\n            -\u003eloadScript($script)\n            -\u003ewithArguments($numbers)\n            -\u003ewithEnvironment(['FIRST_ENV_VAR' =\u003e 10, 'SECOND_ENV_VAR' =\u003e 'second var value'])\n            -\u003etimeout(60)\n            -\u003easJson()\n            -\u003erun();\n\n        print_r(json_encode($result));\n    } catch (\\Exception $e) {\n        print_r(\"Error: \" . $e-\u003egetMessage());\n    }\n  }\n}\n```\n\n---\n\n## ✨ Features\n\n### 🔐 Secure Execution\n- **Path Validation** ✅ Ensures scripts are within allowed directories.\n- **Argument \u0026 Environment Validation** 🔍 Restricts unauthorized input.\n- **Timeout Control** ⏳ Prevents long-running scripts.\n- **black list** for these vars `PATH,PYTHONPATH,LD_LIBRARY_PATH,LD_PRELOAD,PYTHONHOME`, can not passed . \n- **Uses `proc_open` as an alternative to `shell_exec`**.\n\n### 🔧 Flexible Configuration\n- Centralized settings via `ConfigManager`.\n- Customizable execution parameters.\n\n### 📤 Output Handling\n- Supports JSON parsing.\n- Captures and reports script errors.\n\n### 🚨 Error Management\n- Detailed exception handling for debugging.\n- Standardized error reporting.\n\n### 🔌 Extensibility\n- Modular execution through `CommandExecutor`.\n- Customizable for advanced use cases.\n\n---\n### Important Critical Note: \n\n❌ Never pass user-controlled input directly script, just pass scripts that you will need as a administrator (Just from Your side) .\n\n---\n\n## 📋 Changelog\n\nSee detailed release notes in [CHANGELOG.md](CHANGELOG.md) 📜\n\n---\n\n## 🧪 Testing\n\n```bash\n./vendor/bin/pest\n```\n\n---\n\n## 🔒 Security\n\n**Report Vulnerabilities**: Contact [omaralwi2010@gmail.com](mailto:omaralwi2010@gmail.com) 📩\n\n---\n\n## 🤝 Contributors\n\nA huge thank you to these amazing people who have contributed to this project! 🎉💖\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\n      \u003ca href=\"https://github.com/omaralalwi\"\u003e\n        \u003cimg src=\"https://avatars.githubusercontent.com/u/25439498?v=4\" width=\"60px;\" style=\"border-radius:50%;\" alt=\"Omar AlAlwi\"/\u003e\n        \u003cbr /\u003e\n        \u003cb\u003eOmar AlAlwi\u003c/b\u003e\n      \u003c/a\u003e\n      \u003cbr /\u003e\n      🏆 Creator\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n**Want to contribute?** Check out the [contributing guidelines](./CONTRIBUTING.md) and submit a pull request! 🚀\n\n---\n\n## 📄 License\n\nThis package is open-source software licensed under the [MIT License](LICENSE.md). 📜\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaralalwi%2Flaravel-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomaralalwi%2Flaravel-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomaralalwi%2Flaravel-py/lists"}