{"id":13615945,"url":"https://github.com/loophp/nix-php-composer-builder","last_synced_at":"2025-04-14T00:31:23.036Z","repository":{"id":186143719,"uuid":"674644238","full_name":"loophp/nix-php-composer-builder","owner":"loophp","description":"A PHP builder for Composer based projects","archived":true,"fork":false,"pushed_at":"2023-10-08T19:30:51.000Z","size":108,"stargazers_count":13,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-02T20:47:39.750Z","etag":null,"topics":["composer","nix","php"],"latest_commit_sha":null,"homepage":"https://github.com/loophp/nix-php-composer-builder","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loophp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"drupol"}},"created_at":"2023-08-04T12:50:36.000Z","updated_at":"2023-10-08T19:31:41.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2672e34-aa11-4f19-9bd0-b14467714264","html_url":"https://github.com/loophp/nix-php-composer-builder","commit_stats":null,"previous_names":["loophp/nix-php-composer-builder"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Fnix-php-composer-builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Fnix-php-composer-builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Fnix-php-composer-builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loophp%2Fnix-php-composer-builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loophp","download_url":"https://codeload.github.com/loophp/nix-php-composer-builder/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223611618,"owners_count":17173478,"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":["composer","nix","php"],"created_at":"2024-08-01T20:01:21.006Z","updated_at":"2024-11-08T00:30:23.652Z","avatar_url":"https://github.com/loophp.png","language":"Nix","funding_links":["https://github.com/sponsors/drupol"],"categories":["Nix"],"sub_categories":[],"readme":"The features of this flake has been merged in https://github.com/loophp/nix-shell\n\n\u003c!-- # Nix PHP Composer builder\n\nA Nix builder for PHP projects that uses [Composer](https://getcomposer.org/).\n\n## History\n\nThe development of this PHP builder started in April 2023. The objective was to\ncreate a totally new PHP builder capable of building PHP projects using\nComposer. Given that Composer, despite its excellent package management\ncapabilities, lacks the ability to create reproducible builds out of the box,\nthis task posed a significant challenge.\n\n[A pull request](https://github.com/NixOS/nixpkgs/pull/225401) was initiated\nagainst `nixpkgs` and it is currently awaiting for reviews. The entire history\nof the PR is also accessible there.\n\nSimultaneously, I have separated the relevant parts and files of this PR into\nthis current project. This not only allows for greater flexibility in\nimplementing it into existing flakes but also facilitates its enhancement and\nfoster user contributions.\n\nThe idea is that each improvements that are made in this project will be merged\nto some extent in the upstream PR against `nixpkgs`. Once the PR will be merged\nin `nixpkgs`, there will be no reason to keep this repository alive and it will\nbe archived.\n\n## Usage\n\nThis flake provides a default template to get you started quickly. To use it,\nrun:\n\n```bash\nnix flake init --template github:loophp/nix-php-composer-builder#basic\n```\n\nRead more about the [basic template](templates/basic/README.md).\n\nHowever, you can follow the steps below for a more manual approach:\n\n\u003cdetails\u003e\n\n\u003csummary\u003eStep 1\u003c/summary\u003e\n\nAdd a new input to your own flake:\n\n```nix\n{\n  description = \"My PHP project\";\n\n  inputs = {\n    nixpkgs.url = \"github:NixOS/nixpkgs/nixos-unstable\";\n    # Add the following line\n    nix-php-composer-builder.url = \"github:loophp/nix-php-composer-builder\";\n  };\n\n  ...\n\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003eStep 2\u003c/summary\u003e\n\nThis flake provides a default overlay, import it in your own flake:\n\n```nix\npkgs = import inputs.nixpkgs {\n    inherit system;\n    overlays = [\n        inputs.nix-php-composer-builder.overlays.default\n    ];\n};\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\n\u003csummary\u003eStep 3\u003c/summary\u003e\n\nUse the `buildComposerProject` function to build your project:\n\n```nix\nmyPhpProject = pkgs.api.buildComposerProject {\n    # Customize the version of PHP you want to use.\n    # inherit php;\n\n    pname = \"my-php-project\";\n    version = \"1.0.0\";\n\n    src = ; # Your src\n\n    vendorHash = \"sha256-O2+ner833dlj0JSg/paBXcrgk1SuRF6hIdZ7Pn+MCx4=\";\n};\n```\n\n\u003c/details\u003e\n\n## Examples\n\nSee examples on how to package [Drupal](https://github.com/drupal/drupal),\n[Framework-X](https://github.com/clue/framework-x),\n[Mezzio Skeleton](https://github.com/mezzio/mezzio-skeleton),\n[Satis](https://github.com/composer/satis) or\n[Symfony Demo](https://github.com/symfony/demo) in the\n[checks.nix](./tests/checks.nix) file.\n\nThose derivations are also used in the tests to ensure that the builds are\nconsistent.\n\n## Extra\n\nThis flake provides a `buildPhpFromComposer` function, which is designed to\ngenerate an adequate PHP environment from an existing `composer.json` file. It\nensures that the extensions specified within the `composer.json` file are\ncorrectly installed.\n\nInstead of doing:\n\n```nix\nphp = php.withExtensions({enabled, all}: enabled ++ [ all.xsl all.pcov ]);\n```\n\nYou can now just do:\n\n```nix\nphp = pkgs.api.buildPhpFromComposer { inherit src; };\n```\n\nAs long as your `composer.json` list the required extensions in the `require` or\n`require-dev` sections, as such:\n\n```json\n{\n  # ...8\u003c...\n  \"require\": {\n    \"ext-xsl\": \"*\",\n    \"ext-pcov\": \"*\"\n  }\n  # ...\u003e8...\n}\n```\n\nTo modify the PHP configuration, create a file `.user.ini` in the project with\nyour custom PHP configuration directives:\n\n```ini\nmemory_limit=-1\n```\n\n## Testing\n\nTo evaluate this new PHP/Composer builder, a few PHP derivations provided as\nexamples have been written. As the objective of this builder is to guarantee\nreproducible PHP builds, conducting the tests essentially boils down to just\nbuilding these derivations.\n\nTo run the tests, execute the following command:\n\n```shell\nnix flake check ./tests --no-write-lock-file\n```\n\n## Contributing\n\nFeel free to contribute by sending pull requests. We are a usually very\nresponsive team and we will help you going through your pull request from the\nbeginning to the end.\n\nFor some reasons, if you can't contribute to the code and willing to help,\nsponsoring is a good, sound and safe way to show us some gratitude for the hours\nwe invested in this package.\n\nSponsor me on [Github][github sponsors link] and/or any of [the\ncontributors][6].\n\n[github sponsors link]: https://github.com/sponsors/drupol\n[6]: https://github.com/loophp/collection/graphs/contributors --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floophp%2Fnix-php-composer-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floophp%2Fnix-php-composer-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floophp%2Fnix-php-composer-builder/lists"}