Skip to content

Commit 504f131

Browse files
committed
Version 1.0.0
0 parents  commit 504f131

26 files changed

+2920
-0
lines changed

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/.gitattributes export-ignore
2+
/.gitignore export-ignore
3+
/.travis.yml export-ignore
4+
/.scrutinizer.yml export-ignore
5+
/phpspec.yml export-ignore
6+
/phpspec-ci.yml export-ignore
7+
/phpunit.xml export-ignore
8+
/phpunit.xml.dist export-ignore
9+
/tests export-ignore
10+
/spec export-ignore

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/vendor
2+
/.cache
3+
/coverage
4+
coverage.*
5+
composer.phar
6+
.idea
7+
.DS_Store
8+
Thumbs.db

.scrutinizer.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
filter:
2+
excluded_paths:
3+
- 'tests/*'
4+
- 'spec/*'
5+
6+
checks:
7+
php:
8+
code_rating: true
9+
duplication: true
10+
11+
coding_style:
12+
php:
13+
spaces:
14+
around_operators:
15+
negation: true
16+
17+
build:
18+
tests:
19+
override:
20+
-
21+
command: 'vendor/bin/phpspec run -f progress -c phpspec-ci.yml'
22+
coverage:
23+
file: 'coverage.clover'
24+
format: 'php-clover'

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
before_script:
10+
- composer self-update
11+
- composer install --prefer-source --no-interaction --dev
12+
13+
script: vendor/bin/phpspec run

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changelog
2+
3+
All Notable changes to `Flash` will be documented in this file.
4+
5+
## 1.0.0 (2015-05-15)
6+
7+
- Version 1.0.0 of Flash for Laravel 5.
8+
- Flash multiple messages to the session.
9+
- Optionally pass in a translator key to fetch a message translation.
10+
- Add `dismissible` option for alerts (defaults to `true`)

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c) 2015 Ivan Vermeyen (<ivan@codezero.be>)
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in
13+
> all copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
> THE SOFTWARE.

README.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Flash
2+
3+
[![GitHub release](https://img.shields.io/github/release/codezero-be/flash.svg)]()
4+
[![License](https://img.shields.io/packagist/l/codezero/flash.svg)]()
5+
[![Build Status](https://img.shields.io/travis/codezero-be/flash.svg?branch=master)](https://travis-ci.org/codezero-be/flash)
6+
[![Scrutinizer](https://img.shields.io/scrutinizer/g/codezero-be/flash.svg)](https://scrutinizer-ci.com/g/codezero-be/flash)
7+
[![Total Downloads](https://img.shields.io/packagist/dt/codezero/flash.svg)](https://packagist.org/packages/codezero/flash)
8+
9+
### Flash messages to the session with [Laravel 5](http://laravel.com/).
10+
11+
This package is based on the original version of [Laracasts](https://github.com/laracasts/flash), but adds a few extra features:
12+
13+
- Flash multiple messages in one request.
14+
- Pass in a simple message or a key to look up in [Laravel's Translator](http://laravel.com/docs/5.0/localization).
15+
16+
## Laravel 5 Installation
17+
18+
Install this package through Composer:
19+
20+
composer require codezero/flash
21+
22+
Add a reference to `FlashServiceProvider` to the providers array in `config/app.php`:
23+
24+
'providers' => [
25+
'CodeZero\Flash\FlashServiceProvider'
26+
]
27+
28+
If you want to use the facade, then you can also add it there:
29+
30+
'aliases' => [
31+
'Flash' => 'CodeZero\Flash\Facade\Flash'
32+
]
33+
34+
## Usage
35+
36+
You can flash a message to the session in your controllers, before you redirect.
37+
38+
### 3 Ways to Flash...
39+
40+
You can use the facade...
41+
42+
Flash::info('message');
43+
44+
... or the helper method...
45+
46+
flash()->info('message');
47+
48+
... or you can inject `CodeZero\Flash\Flasher` in your controller and call it like this:
49+
50+
$this->flash->info('message');
51+
52+
### Flash Types
53+
54+
Flash::info('info message');
55+
Flash::success('success message');
56+
Flash::warning('warning message');
57+
Flash::error('error message');
58+
Flash::overlay('modal overlay message', 'Message Title');
59+
60+
### Multiple Flashes
61+
62+
You can flash any number of messages of any type.
63+
In your view, you can use `@foreach` to run through them (see below).
64+
65+
Flash::success('success message');
66+
Flash::warning('warning message');
67+
68+
... or...
69+
70+
Flash::success('success message')->warning('warning message');
71+
72+
### Dismissible Messages
73+
74+
By default an `alert-dismissible` class is added and a close button is shown.
75+
If you don't want this, you can pass `false` as the third argument.
76+
Obviously an overlay message is always dismissible and does not have this option.
77+
78+
Flash::success('success message', [], false);
79+
80+
> Dismissing alerts requires some javascript from [Bootstrap](http://getbootstrap.com/getting-started/), or your own.
81+
82+
### Localization
83+
84+
If you want to fetch a localized message from [Laravel's Translator](http://laravel.com/docs/5.0/localization),
85+
then you can pass in the translation key instead of a message.
86+
As a second parameter, you can optionally provide an array of placeholder values for the translated string.
87+
88+
Flash::error('users.user_not_found', ['id' => $id]);
89+
Flash::overlay('users.user_not_found', 'users.title', ['id' => $id]);
90+
91+
This would look for an array key `user_not_found` and `title` in `resources/lang/en/users.php` (if your locale is `en`)
92+
and replace `:id` with the actual `$id`.
93+
94+
'user_not_found' => 'There is no user with the ID of :id.'
95+
'title' => 'User :id Not Found'
96+
97+
### Show the Messages
98+
99+
In your master view, simply include a partial:
100+
101+
@include('flash::message')
102+
103+
A full example with [Bootstrap](http://getbootstrap.com/):
104+
105+
<!DOCTYPE html>
106+
<html lang="en">
107+
<head>
108+
<meta charset="UTF-8">
109+
<title>Document</title>
110+
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
111+
</head>
112+
<body>
113+
114+
<div class="container">
115+
116+
@include('flash::message')
117+
118+
<p>Welcome...</p>
119+
120+
</div>
121+
122+
<script src="//code.jquery.com/jquery.js"></script>
123+
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
124+
125+
<!-- This is only necessary if you do Flash::overlay('...') -->
126+
<script>
127+
$('#flash-overlay-modal').modal();
128+
</script>
129+
130+
</body>
131+
</html>
132+
133+
### Customize the Messages
134+
135+
If you want to customize the templates you can publish the views:
136+
137+
php artisan vendor:publish --provider="CodeZero\Flash\FlashServiceProvider" --tag="views"
138+
139+
> You will find the views in `resources/views/vendor/codezero/flash`.
140+
141+
If you want to change the class names or session key, publish the configuration file:
142+
143+
php artisan vendor:publish --provider="CodeZero\Flash\FlashServiceProvider" --tag="config"
144+
145+
> You will find the configuration file at `config/flash.php`.
146+
147+
## Testing
148+
149+
$ vendor/bin/phpspec run
150+
151+
## Security
152+
153+
If you discover any security related issues, please [e-mail me](mailto:ivan@codezero.be) instead of using the issue tracker.
154+
155+
## License
156+
157+
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
158+
159+
---
160+
[![Analytics](https://ga-beacon.appspot.com/UA-58876018-1/codezero-be/flash)](https://github.com/igrigorik/ga-beacon)

composer.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "codezero/flash",
3+
"description": "Clean flash message system for Laravel.",
4+
"keywords": [
5+
"flash",
6+
"message",
7+
"session",
8+
"form",
9+
"laravel"
10+
],
11+
"license": "MIT",
12+
"authors": [
13+
{
14+
"name": "Ivan Vermeyen",
15+
"email": "ivan@codezero.be"
16+
}
17+
],
18+
"require": {
19+
"php": ">=5.4.0"
20+
},
21+
"require-dev": {
22+
"phpspec/phpspec": "~2.0",
23+
"henrikbjorn/phpspec-code-coverage": "~1.0",
24+
"illuminate/session": "~5.0",
25+
"illuminate/translation": "~5.0",
26+
"illuminate/support": "~5.0"
27+
},
28+
"autoload": {
29+
"psr-4": {
30+
"CodeZero\\Flash\\": "src/"
31+
},
32+
"files": [
33+
"src//helpers.php"
34+
]
35+
},
36+
"minimum-stability": "stable"
37+
}

0 commit comments

Comments
 (0)