-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
223 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/vendor/ | ||
/build/ | ||
/composer.lock | ||
/phpunit.xml | ||
/.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,50 @@ | ||
# laravel-mime | ||
# Laravel Mime | ||
|
||
[![Latest Version](http://img.shields.io/packagist/v/astrotomic/laravel-mime.svg?label=Release&style=for-the-badge&cacheSeconds=600)](https://packagist.org/packages/astrotomic/laravel-mime) | ||
[![MIT License](https://img.shields.io/github/license/Astrotomic/laravel-mime.svg?label=License&color=blue&style=for-the-badge&cacheSeconds=600)](https://github.com/Astrotomic/laravel-mime/blob/master/LICENSE) | ||
[![Offset Earth](https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-green?style=for-the-badge&cacheSeconds=600)](https://offset.earth/treeware) | ||
|
||
This package provides Laravel service bindings for [symfony/mime](https://symfony.com/doc/current/components/mime.html). | ||
|
||
## Installation | ||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require astrotomic/laravel-mime | ||
``` | ||
|
||
## Usage | ||
|
||
``` php | ||
// facade | ||
use Astrotomic\LaravelMime\Facades\MimeTypes; | ||
|
||
// container bindings | ||
app('laravel-mime'); | ||
app(\Symfony\Component\Mime\MimeTypes::class); | ||
app(\Symfony\Component\Mime\MimeTypesInterface::class); | ||
app(\Symfony\Component\Mime\MimeTypeGuesserInterface::class); | ||
``` | ||
|
||
## Credits | ||
|
||
- [Tom Witkowski](https://github.com/Gummibeer) | ||
- [All Contributors](../../contributors) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE) for more information. | ||
|
||
## Treeware | ||
|
||
You're free to use this package, but if it makes it to your production environment I would highly appreciate you buying the world a tree. | ||
|
||
It’s now common knowledge that one of the best tools to tackle the climate crisis and keep our temperatures from rising above 1.5C is to [plant trees](https://www.bbc.co.uk/news/science-environment-48870920). If you contribute to my forest you’ll be creating employment for local families and restoring wildlife habitats. | ||
|
||
You can buy trees at https://offset.earth/treeware | ||
|
||
Read more about Treeware at https://treeware.earth | ||
|
||
[![We offset our carbon footprint via Offset Earth](https://toolkit.offset.earth/carbonpositiveworkforce/badge/5e186e68516eb60018c5172b?black=true&landscape=true)](https://offset.earth/treeware) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "astrotomic/laravel-mime", | ||
"description": "Laravel wrapper for symfony/mime", | ||
"keywords": [ | ||
"astrotomic", | ||
"laravel-mime" | ||
], | ||
"homepage": "https://github.com/astrotomic/laravel-mime", | ||
"license": "MIT", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Tom Witkowski", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.4", | ||
"illuminate/support": "^6.0", | ||
"symfony/mime": "^5.0" | ||
}, | ||
"require-dev": { | ||
"orchestra/testbench": "^4.5", | ||
"phpunit/phpunit": "^8.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Astrotomic\\LaravelMime\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Astrotomic\\LaravelMime\\Tests\\": "tests" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Astrotomic\\LaravelMime\\MimeTypesServiceProvider" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
/* | ||
* You can place your custom package configuration in here. | ||
*/ | ||
return [ | ||
|
||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/autoload.php" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
verbose="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Astrotomic\LaravelMime\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
use Symfony\Component\Mime\MimeTypesInterface; | ||
|
||
/** | ||
* @method static bool isGuesserSupported() | ||
* @method static null|string guessMimeType(string $path) | ||
* @method static string[] getExtensions(string $mimeType) | ||
* @method static string[] getMimeTypes(string $ext) | ||
* | ||
* @see \Symfony\Component\Mime\MimeTypeGuesserInterface | ||
* @see \Symfony\Component\Mime\MimeTypesInterface | ||
* @see \Symfony\Component\Mime\MimeTypes | ||
*/ | ||
class MimeTypes extends Facade | ||
{ | ||
protected static function getFacadeAccessor(): string | ||
{ | ||
return MimeTypesInterface::class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace Astrotomic\LaravelMime; | ||
|
||
use Illuminate\Contracts\Support\DeferrableProvider; | ||
use Illuminate\Support\ServiceProvider; | ||
use Symfony\Component\Mime\MimeTypeGuesserInterface; | ||
use Symfony\Component\Mime\MimeTypes; | ||
use Symfony\Component\Mime\MimeTypesInterface; | ||
|
||
class MimeTypesServiceProvider extends ServiceProvider implements DeferrableProvider | ||
{ | ||
public function register(): void | ||
{ | ||
$this->app->singleton('laravel-mime',MimeTypes::class); | ||
$this->app->alias('laravel-mime', MimeTypesInterface::class); | ||
$this->app->alias('laravel-mime', MimeTypeGuesserInterface::class); | ||
} | ||
|
||
public function provides(): array | ||
{ | ||
return [ | ||
'laravel-mime', | ||
MimeTypes::class, | ||
MimeTypesInterface::class, | ||
MimeTypeGuesserInterface::class, | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace Astrotomic\LaravelMime\Tests; | ||
|
||
use Astrotomic\LaravelMime\MimeTypesServiceProvider; | ||
use Orchestra\Testbench\TestCase; | ||
use Symfony\Component\Mime\MimeTypeGuesserInterface; | ||
use Symfony\Component\Mime\MimeTypes; | ||
use Symfony\Component\Mime\MimeTypesInterface; | ||
|
||
class MimeTypesTest extends TestCase | ||
{ | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
MimeTypesServiceProvider::class, | ||
]; | ||
} | ||
|
||
/** | ||
* @test | ||
* @dataProvider serviceBindings | ||
*/ | ||
public function it_can_instantiate_service(string $service): void | ||
{ | ||
$this->assertInstanceOf(MimeTypes::class, $this->app->make($service)); | ||
} | ||
|
||
public function serviceBindings(): array | ||
{ | ||
return [ | ||
['laravel-mime'], | ||
[MimeTypes::class], | ||
[MimeTypesInterface::class], | ||
[MimeTypeGuesserInterface::class], | ||
]; | ||
} | ||
} |