balping / laravel-hashslug

Package providing a trait to use Hashids on a model
GNU General Public License v3.0
132 stars 12 forks source link

Enabling / Disabling #10

Closed GGH-Bortels closed 6 years ago

GGH-Bortels commented 6 years ago

Hey,

It would be super awesome to disable the package in development. If I would have an option in the config with "enabled" or so I can debug much better. I don't know a quick hack for this because you can not include traits dynamically in PHP. Is there an exact code line where a quick and dirty "return" disables the whole package?

balping commented 6 years ago

No, I don't thinks so. You could write a small script that swaps the trait file to an empty trait and another one that does the reverse.

GGH-Bortels commented 6 years ago

May u explain this a little further?

balping commented 6 years ago

Like so:

Create an empty trait file:

$ mkdir storage/tmp
<?php
// storage/tmp/empty.php
namespace Balping\HashSlug;
trait HasHashSlug {

}

Copy the original one to this directory

$ cp vendor/balping/laravel-hashslug/src/HasHashSlug.php storage/tmp/real.php

Then you can easily switch between the two:

testmode.sh:

#!/bin/bash
cp  -uf storage/tmp/empty.php vendor/balping/laravel-hashslug/src/HasHashSlug.php

realmode.sh:

#!/bin/bash
cp  -uf storage/tmp/real.php vendor/balping/laravel-hashslug/src/HasHashSlug.php
balping commented 6 years ago

Moved to Gitlab. Issue has also been migrated: https://gitlab.com/balping/laravel-hashslug/issues/10 Continue there if necessary.