Skip to content

Commit

Permalink
Actually fix PHP extensions (#829)
Browse files Browse the repository at this point in the history
* Actually fix PHP extensions

* fmt + clippy

* Update snapshots, don't fail when composer.json doesn't exist

* Make composer not explode

* Update snapshots
  • Loading branch information
aleksrutins authored Mar 15, 2023
1 parent 78d307f commit 93cb958
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
27 changes: 17 additions & 10 deletions src/providers/php/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,28 @@ impl PhpProvider {
Ok(php_package) => php_package,
_ => "php".to_string(),
};

let php_extensions = PhpProvider::get_php_extensions(app).unwrap_or(vec![]);

let mut pkgs = vec![
Pkg::new(&php_pkg),
Pkg::new(&format!(
r"({}.withExtensions (pe: pe.enabled ++ [{}]))",
&php_pkg,
php_extensions
.iter()
.map(|ext| format!("pe.all.{ext}"))
.collect::<Vec<_>>()
.join(" ")
)),
Pkg::new("perl"),
Pkg::new("nginx"),
Pkg::new("libmysqlclient"),
Pkg::new(&format!("{}Packages.composer", &php_pkg)),
];
let ext_pkgs = if let Ok(php_extensions) = PhpProvider::get_php_extensions(app) {
php_extensions
.iter()
.map(|extension| format!("{}Extensions.{extension}", &php_pkg))
.collect()
} else {
vec![]
};
let ext_pkgs: Vec<String> = php_extensions
.iter()
.map(|extension| format!("{}Extensions.{extension}", &php_pkg))
.collect();

if app.includes_file("package.json") {
pkgs.append(&mut NodeProvider::get_nix_packages(app, env)?);
Expand All @@ -93,7 +100,7 @@ impl PhpProvider {
"mkdir -p /var/log/nginx && mkdir -p /var/cache/nginx".to_string(),
));
if app.includes_file("composer.json") {
install.add_cmd("composer install".to_string());
install.add_cmd("composer install --ignore-platform-reqs".to_string());
};
if app.includes_file("package.json") {
if let Some(install_cmd) = NodeProvider::get_install_command(app) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ expression: plan
"setup": {
"name": "setup",
"nixPkgs": [
"php",
"(php.withExtensions (pe: pe.enabled ++ []))",
"perl",
"nginx",
"libmysqlclient",
Expand Down
4 changes: 2 additions & 2 deletions tests/snapshots/generate_plan_tests__php_laravel.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ expression: plan
],
"cmds": [
"mkdir -p /var/log/nginx && mkdir -p /var/cache/nginx",
"composer install",
"composer install --ignore-platform-reqs",
"npm i"
]
},
"setup": {
"name": "setup",
"nixPkgs": [
"php81",
"(php81.withExtensions (pe: pe.enabled ++ []))",
"perl",
"nginx",
"libmysqlclient",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ expression: plan
],
"cmds": [
"mkdir -p /var/log/nginx && mkdir -p /var/cache/nginx",
"composer install",
"composer install --ignore-platform-reqs",
"npm i"
]
},
"setup": {
"name": "setup",
"nixPkgs": [
"php81",
"(php81.withExtensions (pe: pe.enabled ++ [pe.all.mongodb]))",
"perl",
"nginx",
"libmysqlclient",
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshots/generate_plan_tests__php_vanilla.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ expression: plan
"setup": {
"name": "setup",
"nixPkgs": [
"php",
"(php.withExtensions (pe: pe.enabled ++ []))",
"perl",
"nginx",
"libmysqlclient",
Expand Down

0 comments on commit 93cb958

Please sign in to comment.