{"id":16382347,"url":"https://github.com/ferpetrelli/live-statics","last_synced_at":"2026-04-14T06:33:59.412Z","repository":{"id":57038246,"uuid":"165098642","full_name":"ferpetrelli/live-statics","owner":"ferpetrelli","description":"Rapid development aid package that facilitates data modelling and dynamic integration with views","archived":false,"fork":false,"pushed_at":"2021-01-30T04:01:13.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-03T13:03:38.828Z","etag":null,"topics":["composer","injection","laravel","package","php","statics"],"latest_commit_sha":null,"homepage":null,"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/ferpetrelli.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-10T17:02:59.000Z","updated_at":"2021-01-30T04:01:15.000Z","dependencies_parsed_at":"2022-08-23T20:51:00.653Z","dependency_job_id":null,"html_url":"https://github.com/ferpetrelli/live-statics","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ferpetrelli/live-statics","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferpetrelli%2Flive-statics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferpetrelli%2Flive-statics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferpetrelli%2Flive-statics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferpetrelli%2Flive-statics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ferpetrelli","download_url":"https://codeload.github.com/ferpetrelli/live-statics/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ferpetrelli%2Flive-statics/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31785677,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["composer","injection","laravel","package","php","statics"],"created_at":"2024-10-11T04:05:03.476Z","updated_at":"2026-04-14T06:33:59.394Z","avatar_url":"https://github.com/ferpetrelli.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About Live-Statics\n\n[![Build Status](https://travis-ci.org/ferpetrelli/live-statics.svg?branch=master)](https://travis-ci.org/ferpetrelli/live-statics)\n\nThe `petrelli\\live-statics` package provides a quick way to generate and integrate fake prototypes into our system. Mocked objects can easily be model to behave as the real ones, so you won't have to spend any time with integration tasks.\n\nBoth real and mocked data sources will live together so you will be able you to switch between them at any time by simply changing the subdomain.\n\nA great secondary effect is that because our fake objects behave as real, a fully functional 'live static' version of your web application will be accessible to explore and click around.\n\nFaker content can be parametrized, so your 'live statics' will change by just passing some URL parameters. This will come incredibly handy to perform visual QA, client presentations, and simply just to have a glance on how your site will behave with different types of content.\n\n# Quick demo\n\nLet's explore a few links:\n\n1. \u003ca href=\"http://fernandopetrelli.com\" target=\"_blank\"\u003eOpen\u003c/a\u003e. A real personal website.\n2. \u003ca href=\"http://static.fernandopetrelli.com\" target=\"_blank\"\u003eOpen\u003c/a\u003e. Same URL with a `static` subdomain.\n\nNotice the Projects list. It's just a simple loop within an Eloquent model collection.\n\nThe second link, is also a collection, but instead of Eloquent it's using our mocked models. Views and controller are the same for both URL's.\n\n\n# Install\n\n1. Include the package\n\nYou can run the command:\n\n```bash\ncomposer require petrelli/live-statics\n```\n\nOr directly add it to your composer.json\n\n```json\n\"petrelli/live-statics\": \"^0.0.1\"\n```\n\nAnd run `composer update`.\n\n\n2. If you have Package Auto-discovery (Laravel 5.5+ by default) skip to step 3, otherwise you'll have to manually add the service provider to your `config/app.php` file.\n\n```php\n'providers' =\u003e [\n    //...\n    Petrelli\\LiveStatics\\BaseServiceProvider::class,\n    //...\n]\n```\n\n3. Publish configuration files and the Service Provider\n\n```\nphp artisan vendor:publish --provider=\"Petrelli\\LiveStatics\\BaseServiceProvider\"\n```\n\n\n# Usage\n\n\n## Create a new mocked class, and it's interface\n\n\n1. Generate a new Mocked class (e.g. Project). Run the command:\n\n```bash\nphp artisan live-statics:class Project\n```\n\nThis will use the configuration values inside `config/live-statics.php` to generate a base mocked class `Project`, plus an interface `ProjectInterface` that will allow you to bind it to the real or fake implementation.\n\n2. Add binding instructions to `config/live-statics.php`\n\n```php\n'mocked_classes' =\u003e [\n    \\App\\Interfaces\\ProjectInterface::class =\u003e [\n        \\App\\Mocks\\ProjectMock::class, \\App\\Project::class\n    ],\n],\n```\n\nConvention is the following:\n\n```\n'mocked_classes' =\u003e [\n    INTERFACE1 =\u003e [ MOCKED_CLASS1, REAL_CLASS1 ],\n    //...\n    INTERFACEn =\u003e [ MOCKED_CLASSn, REAL_CLASSn ],\n]\n```\n\nThis will be enough to use your interfaces to inject them properly!\n\nIf your real class is not ready yet and you just want a quick prototype, pass `null` as the second element of the array.\n\n```\n'mocked_classes' =\u003e [\n    INTERFACE1 =\u003e [ MOCKED_CLASS1, null ],\n    //...\n]\n```\n\n\n## Once you have your Mocked classes, remember to implement the interface in the real one.\n\nFollowing our project example:\n\n```php\nuse App\\Interfaces\\ProjectInterface;\n\nclass Project extends Model implements ProjectInterface\n{\n    #...\n}\n```\n\n## Using your newly created mocked elements\n\nLet's use a controller as an example:\n\n```php\nuse \\App\\Interfaces\\ProjectInterface;\n\nclass Controller extends BaseController\n{\n    public function index(ProjectInterface $model)\n    {\n        # Use your Project instance as normal\n        # $model-\u003eall();\n        # $model-\u003epublished()-\u003eget();\n    }\n}\n\n```\n\nHere we inject `ProjectInterface` to the controller. This will bind the real, or mocked implementation depending on the subdomain.\n\nIf you are not confortable injecting dependencies as formal parameters you can use Laravels `app` function:\n\n```php\nuse \\App\\Interfaces\\ProjectInterface;\n\n\nclass Controller extends BaseController\n{\n    public function index()\n    {\n        $model = app(ProjectInterface:class);\n\n        # Use your Project instance as normal\n        # $model-\u003eall();\n        # $model-\u003epublished()-\u003eget();\n    }\n}\n\n```\n\n\nThat's it!\n\nYou can change this subdomain modifying the `subdomain` option inside `config/live-statics.php`.\n\n\n## Shortcut for Eloquent models\n\nThis is a special case of a general class.\n\nThe package will provide a quick way for you to bind models, as most applications will be mainly mocking Eloquent models.\n\n\n1. Generate the mocked model\n\n```bash\nphp artisan live-statics:model Project\n```\n\n2. Add binding instructions to `config/live-statics.php`\n\n```php\n'mocked_models' =\u003e [\n    'Project',\n]\n```\n\nNotice instead of `mocked_classes`, we use `mocked_models`, and just pass the model's name.\n\nThe package will use path configurations for models provided on `config/live-statics.php` to bind them properly.\n\n\n\n\n\n## Add a custom namespace when creating new mocked classes or models\n\nKeep your code organized creating namespaces for your mocked elements. Folders will be generated automatically.\n\nThis can be easily done passing by a second parameter to both commands:\n\n```bash\n# Prepend Api to the new class namespace\nphp artisan live-statics:class Project Api\n\n# Prepend Api\\Version1 to the new class namespace\nphp artisan live-statics:class Project Api\\\\Version1 #or\nphp artisan live-statics:class Project Api/Version1\n\n# Prepend Api to the new model namespace\nphp artisan live-statics:model Project Api\n\n# Prepend Api\\Version1 to the new model namespace\nphp artisan live-statics:model Project Api\\\\Version1 #or\nphp artisan live-statics:model Project Api/Version1\n```\n\nWhen creating models, the namespace specified within `config/live-statics.php` will be added automatically.\n\n\n# Extra functionalities\n\nDocs to be completed.\n\n## Dynamic parameters\n\nDocs to be completed.\n\n## Namespaces and directories configuration\n\nDocs to be completed.\n\n## Extending Faker through providers\n\nDocs to be completed.\n\n## Creating different versions of your mocked classes\n\nDocs to be completed.\n\n## Modifying your statics in real time through URL parameters\n\nDocs to be completed.\n\n## Partial mocking\n\nDocs to be completed.\n\n\n# License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferpetrelli%2Flive-statics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fferpetrelli%2Flive-statics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fferpetrelli%2Flive-statics/lists"}