Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Composer Copy File

Composer Copy File Laravel Package

slowprog/composer-copy-file

Composer script handler that copies files and directories after install/update. Configure mappings in composer.json (supports dev vs prod rules), nested directories, and overwrite control (override or only if older). Useful for publishing vendor assets like fonts/JS/CSS.

View on GitHub
Deep Wiki
Context7

Composer script copying your files after install

Frequently asked questions about Composer Copy File
How do I install and configure slowprog/composer-copy-file for Laravel?
Add the package to your `composer.json` under `require`, then define `post-install-cmd` and `post-update-cmd` scripts to trigger `SlowProg\CopyFile\ScriptHandler::copy`. Configure source/destination paths in the `extra.copy-file` section. Example: `"extra": { "copy-file": { "vendor/package/file": "public/" } }`.
Does this package work with Laravel 9/10 and PHP 8.x?
The package supports PHP 7.2+, but since it hasn’t been updated since 2020, compatibility with PHP 8.x or Laravel 9/10 isn’t guaranteed. Test thoroughly, or use native Composer scripts as a fallback. No PHP 8-specific features are used, so basic functionality may still work.
Can I copy files conditionally (e.g., only in staging or production)?
No, this package doesn’t support environment-specific copying. Use the `-dev` suffix in `extra.copy-file-dev` for dev-only files, but conditional logic (e.g., `.env`-based) requires a custom script. For Laravel, consider `vendor:publish` with `--tag` or environment checks in a custom Artisan command.
What happens if the destination file already exists?
By default, existing files are overwritten. To skip updates, append `?` to the destination path (e.g., `"public/file.txt?"`). There’s no built-in conflict resolution—custom logic would require a script workaround or alternative package.
Is there a Laravel-native alternative to this package?
Yes. For package-specific files, use Laravel’s `vendor:publish` (e.g., `php artisan vendor:publish --tag=config`). For custom files, create an Artisan command or use Composer’s native `post-install-cmd` with a custom PHP script. These are more maintainable and Laravel-idiomatic.
How do I copy an entire directory structure (e.g., vendor assets to public/)?
Define the source directory with a trailing slash in `extra.copy-file`. Example: `"vendor/package/assets/": "public/vendor-assets/"` will recursively copy all files. Ensure the destination directory exists or use `mkdir -p` in a pre-script.
Will this package slow down Composer installs in production?
No, file copying only runs during `composer install` or `update`, not at runtime. However, large directories may increase initial setup time. For production, consider caching or using Laravel’s `mix`/`vite` for assets instead.
Can I use this to publish Laravel package configs (like config files)?
Technically yes, but Laravel’s `vendor:publish` is the recommended way for package configs. This package is better suited for non-package files (e.g., custom assets, vendor-specific resources). Avoid mixing approaches to prevent conflicts.
What if the package stops working due to Composer/PHP updates?
Since it’s unmaintained, test it with your Composer/PHP versions. If it fails, replace it with native Composer scripts (e.g., `"post-install-cmd": ["php", "copy-files.php"]`) or a maintained alternative like `cweagans/composer-patches`. Document the fallback in your project.
Does this package support copying files from outside the vendor directory?
No, this package is designed to copy files *from* the vendor directory (e.g., `vendor/package/file`) to your project. For copying local files, use a custom script or Laravel’s filesystem utilities (e.g., `File::copy()` in a service provider).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle