Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: transform of string #11

Open
egooktafanda97 opened this issue Mar 16, 2024 · 1 comment
Open

[Feature Request]: transform of string #11

egooktafanda97 opened this issue Mar 16, 2024 · 1 comment

Comments

@egooktafanda97
Copy link

Feature Description

What if the form is not a stub file but rather the syntax of a string that has been manipulated.
Screenshot 2024-03-16 164955

Is this feature valuable for other users as well and why?

may be

@touhidurabir
Copy link
Owner

@egooktafanda97 bit confused about the requested feature . are you asking about if we need pass a string rather than from file ? right now that functionality not present there but I think it's possible to achieve that using the tempfile method like

$file = tmpfile();
// here one can add the string content to temp file 
// fwrite($file, "writing to tempfile"); 
fseek($file, 0);
$filepath = stream_get_meta_data($file)["uri"];

// now that we have the file path with content written to it, we can use it for stub to class generation
StubGenerator::from($filepath, true) // the stub file path as full/absolute path, second param instruct to use it as fullPath
    ->to('some/path/to/store/generated/file') // the store directory path
    ->as('TheGeneratingFileNameItself') // the generatable file name without extension 
    ->ext('php') // the file extension(optional, by default to php)
    // ->noExt() // to remove the extension from the file name for the generated file like .env
    ->withReplacers([]) // the stub replacing params
    ->save(); // save the file

fclose($file); // better to destroy the resource once we are done .

did not test the above code but should work.

If I am mistaken, can you explain in details ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants