<commit_before># Flasher

A simple PHP (5.3+) package to ease the process of displaying feedback to users of your website as they interact with it.

This package comes in handy when you want to provide some feedback to the user on the next page load, after they complete certain actions on your site. For example, a messaging confirming that they have successfully signed up, or deleted their account.

## Installation

The easiest and best way to install the package is via [Composer](http://getcomposer.org). 
Add the ```spanky/flasher``` package to your requirements, and ```composer install```.

```json
{
    "require": {
        "spanky/flasher": "dev-master"
    }
}
``` 
Once the package has been installed, ensure the Composer autoloader is required before 
trying to use Flasher.

```php
    require 'vendor/autoload.php';
```


## Usage

To get up and running, first we need to make an instance of the ```Spanky\Flasher\FlasherManager``` class. 

To do so, simply call the ```make()``` method on the ```Spanky\Flasher\Factory``` class.

```php
<?php

use Spanky\Flasher\Factory as Flasher;

$flasher = Flasher::make();
```

### Setting messages

To set a message to be displayed on the next page load, call the ```addMessage()``` method, 
passing in the content of the message.

```php
$flasher->addMessage('Welcome to the website!');

$flasher->addMessage('Congratulations, you are now signed up!', 'success');

$flasher->addMessage('Oh no, something went wrong!', 'error');
```
The first parameter is the content of the message you wish to be displayed to the user. This must 
be either a string, or an object implementing the ```__toString()``` method.

Notice how you can specify an optional string to denote the type of message being provided as 
either the second parameter of the ```addMessage()``` method.

If you wish, you can also add messages of a specific type in the following way:

```php
$flasher->addSuccess('Congratulations, you are now signed up!');
// identical to $flasher->addMessage('Congratulations, you are now signed up!', 'success');
```

### Displaying messages

When it comes to actually displaying the messages to the user, there are a few methods to 
help you do this with the most flexibility.<commit_msg>updated readme to mention session_start() requirement<commit_after># Flasher

A simple PHP (5.3+) package to ease the process of displaying feedback to users of your website as they interact with it.

This package comes in handy when you want to provide some feedback to the user on the next page load, after they complete certain actions on your site. For example, a messaging confirming that they have successfully signed up, or deleted their account.

## Installation

The easiest and best way to install the package is via [Composer](http://getcomposer.org). 
Add the ```spanky/flasher``` package to your requirements, and ```composer install```.

```json
{
    "require": {
        "spanky/flasher": "dev-master"
    }
}
``` 
Once the package has been installed, ensure the Composer autoloader is required before 
trying to use Flasher.

```php
    require 'vendor/autoload.php';
```


## Usage

To get up and running, first we need to make an instance of the ```Spanky\Flasher\FlasherManager``` class. 

To do so, simply call the ```make()``` method on the ```Spanky\Flasher\Factory``` class.

```php
<?php

use Spanky\Flasher\Factory as Flasher;

$flasher = Flasher::make();
```

If using the ```Spanky\Flasher\MessageStore\SessionMessageStore``` implementation (the default) to 
store messages between page loads, ensure that the session is started before initialising the package:

```php
session_start();
```

### Setting messages

To set a message to be displayed on the next page load, call the ```addMessage()``` method, 
passing in the content of the message.

```php
$flasher->addMessage('Welcome to the website!');

$flasher->addMessage('Congratulations, you are now signed up!', 'success');

$flasher->addMessage('Oh no, something went wrong!', 'error');
```
The first parameter is the content of the message you wish to be displayed to the user. This must 
be either a string, or an object implementing the ```__toString()``` method.

Notice how you can specify an optional string to denote the type of message being provided as 
either the second parameter of the ```addMessage()``` method.

If you wish, you can also add messages of a specific type in the following way:

```php
$flasher->addSuccess('Congratulations, you are now signed up!');
// identical to $flasher->addMessage('Congratulations, you are now signed up!', 'success');
```

### Displaying messages

When it comes to actually displaying the messages to the user, there are a few methods to 
help you do this with the most flexibility.
{'fraction_non_alphanumeric': 0.10320956576463185, 'fraction_numerical': 0.0008391021606880638, 'mean_word_length': 4.583138173302108, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1933812', 'n_tokens_mistral': 1378, 'n_tokens_neox': 1323, 'n_words': 645}