Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ For specific instructions on how to configure each provider, please view their d
aws-provider
iron-mq-provider
sync-provider
file-provider
custom-provider

Caching
Expand Down
4 changes: 2 additions & 2 deletions docs/file-provider.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
File Provider
-------------

The file provider uses the filesystem to dispatches and resolves queued messages.
The file provider uses the filesystem to dispatch and resolve queued messages.

Configuration
^^^^^^^^^^^^^

To designate a queue as file, set the ``driver`` of its provider to ``file``. You will
need to a read-able and write-able path to store the messages.
need to configure a readable and writable path to store the messages.

.. code-block:: yaml

Expand Down
8 changes: 5 additions & 3 deletions src/Provider/FileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ public function publish(array $message, array $options = [])
$fileName = microtime(false);
$fileName = str_replace(' ', '', $fileName);
$path = substr(hash('md5', $fileName), 0, 3);
if (!is_dir($this->queuePath.DIRECTORY_SEPARATOR.$path)) {
mkdir($this->queuePath.DIRECTORY_SEPARATOR.$path);
}

$fs = new Filesystem();
if (!$fs->exists($this->queuePath.DIRECTORY_SEPARATOR.$path)) {
$fs->mkdir($this->queuePath.DIRECTORY_SEPARATOR.$path);
}

$fs->dumpFile(
$this->queuePath.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$fileName.'.json',
json_encode($message)
Expand Down