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

Added migration guide #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions MIGRATING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Migrating From Stapler

Although most functionality from Stapler exists in this package, there are a few
key differences between the two.

## Differences from Stapler
- One major difference is that the `convert_options` configuration settings are no longer available. Conversion options are now handled at the level of the variant strategies. You can set them per attachment configuration, or modify the variant strategy to use a custom global configuration.

- The Paperclip equivalent for `STAPLER_NULL` is `Czim\Paperclip\Attachment\Attachment::NULL_ATTACHMENT`.

- Another difference is that this package does not handle (s3) storage. All storage is performed through Laravel's storage drivers and configuration.

- The refresh command (`php artisan paperclip:refresh`) is very similar to stapler's refresh command, but it can optionally take a `--start #` and/or `--stop #` option, with ID numbers. This makes it possible to refresh only a subset of models. _Under the hood, the refresh command is also much less likely to run out of memory (it uses a generator to process models in chunks)._

- A final change is that the trait uses its own boot method, not the global Model's `boot()`, making this package less likely to conflict with other traits and model implementations.

## Migrating from Stapler
Remove the `laravel-stapler` composer dependency and add paperclip via `composer require czim/laravel-paperclip`

Add the service provider to the `config/app.php` file:
``` php
Czim\Paperclip\Providers\PaperclipServiceProvider::class,
```

Publish the configuration file
``` bash
php artisan vendor:publish --provider="Czim\Paperclip\Providers\PaperclipServiceProvider"
```
_Make sure to remove any reference to the Stapler service provider_

Change references of `Codesleeve\Stapler\ORM\EloquentTrait` to `Czim\Paperclip
Model\PaperclipTrait`

Change references of `Codesleeve\Stapler\ORM\StaplerableInterface` to `Czim\Paperclip\Contracts\AttachableInterface`

Change references of `STAPLER_NULL` to use `Czim\Paperclip\Attachment\Attachment::NULL_ATTACHMENT`
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ With:

This should now include placeholders to make a full file path including the filename, as opposed to only a directory. Note that this makes the path interpolation logic more in line with the way Stapler handled it.

Although this package implements most features from Stapler, there are a few key differences. [See the migration guide](MIGRATING.md) for more information

## Contributing

Expand Down