liner error on unlink and file_put_contents

Permalink
Hi,
i got errors on c5 liner using "unlink" and "file_put_contents" on a block i'm going to submit to marketplace

The block loads and works perfect on my sites.

So are this command deprecated ? but I've seen they are used also in core C5 (even with @ before), If deprecated what can I use instead of this ? or is it a liner problem ?

Can somebody help me ?

Thank you so much in advance
Michele form Rome

1 Attachment

View Replies:
JohntheFish replied on at Permalink Reply
JohntheFish
There are many places where the core uses code that is not acceptable in marketplace packages. Usually its legacy code that one day may get modernised. It may also be the part of the core that provides the higher level service interface.

ie. A new package needs to conform to best practice at the time it is approved, not what was acceptable practice N years ago.

Current best practice is to use the c5 file helper service. If that doesn't support what you need, use flysystem (bundled with the core).
skau61 replied on at Permalink Reply
Thank you so much for answer

I've solved 'file_get_contents()' using 'c5 getContents()' calling \Core::make('helper/file')

But I can't find a solution for unlik a single file.... in '\Core::make('helper/file')' the only function available is 'removeAll()' but it focuses on a folder (and files in them) and NOT to a single file

Can you suggest me where to serach the appropriate function in C5, knowing that file to be deleted is NOT loaded from C5 file function ?

Thank you so much in advance
Michele
JohntheFish replied on at Permalink Reply
JohntheFish
Rather than Core::make, use $app (in a controller already available as $this->app)

To unlink a file, use FlySystem - its included in the corehttps://github.com/thephpleague/flysystem...