Skip to content

[PHP] Add cp method to Universal PHP#3234

Open
mho22 wants to merge 1 commit intotrunkfrom
add-copy-method-to-universal-php
Open

[PHP] Add cp method to Universal PHP#3234
mho22 wants to merge 1 commit intotrunkfrom
add-copy-method-to-universal-php

Conversation

@mho22
Copy link
Collaborator

@mho22 mho22 commented Feb 2, 2026

Motivation for the change, related issues

Based on this issue

While playing with PHP.wasm, I found out it has a mv method, but no cp method.

Implementation details

Using directly FSHelpers.copyRecursive inside the php.cp() method

Testing Instructions

cp.ts :

import { PHP } from '@php-wasm/universal';
import { loadNodeRuntime } from "@php-wasm/node";

const php = new PHP(await loadNodeRuntime('8.5'));

php.mkdir('test');

php.chdir('test');

php.writeFile('foo', `<?php echo "File copied successfully";`);

php.cp('foo', 'bar');

const response = await php.runStream({scriptPath: 'bar'});

console.log(await response.stdoutText, php.listFiles('/test'));

Output :

> node cp.ts

File copied successfully [ 'foo', 'bar' ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant