Full Documentation

Version: 1.0.1

Welcome

Atomos is a WordPress development framework, it’s aimed to bring a modern taste to WordPress development.

The framework brings verbose functions into WordPress (also known as syntactic sugar) to keep the code clean and readable (we all know how messy WordPress functions can get).

The framework is loosely based on techniques taken from the Laravel framework. So you may notice some similarities. If you’ve developed in Laravel before, you may rather enjoy Atomos. Dont worry, Laravel experience is not required.

It’s aimed to bring rapid development to your WordPress sites in a structured approach. It will help keep your code clean.

Architecture

Atomos is bu­­­ilt to cover most requirements for WordPress development.

It comes in 3 parts:

  • Atomos Core Plugin – Atomos core is required for both the Atomos plugin framework or Atomos theme.
  • Atomos Plugin – This is a plugin framework to get you started with writing plugins quicker.
  • Atomos Theme This is a starter theme with tools to help with quicker and cleaner theme development.

As noted above. The Atomos Core Plugin is always required to use either Atomos Plugin or Atomos Theme within your WordPress installation. Most functionality and core features are within Atomos Core.

This means you can always use the core functionality within your plugins or your themes. It also keeps your projects upgradable. Always giving you the latest functionality with little work to current code.

Notice

Please note, you should never update or add code to the Atomos Core plugin as it will be overwritten with any major or minor updates. You should always do custom code and additional functionality within your plugin or themes codebase, not Atomos Cores codebase.

Installation

To install Atomos framework, simple download, install and activate the Atomos Core Plugin via the WordPress dashboard. You’ll then have the core features available throughout your codebase.

Download Links:

You can now install and activate the Atomos Plugin to get started with plugin development. Download and activate the Atomos Theme to get started with theme development.

The last thing you’ll have to do to get the full benefits of Atomos is to define the ATOMOS_ENV constant in your wp-config.php file.

Example:
define('ATOMOS_ENV', 'DEV');

Some development tools will be enabled if you use any of the following values: DEV, LOCAL.

Requirements

  • Wordpress 4.9.4 > (not tested on anything below this.)
  • PHP 5.6 >
  • Preferably a fresh installation of Wordpress

Routing

Routing requests in Atomos is a core part for writing custom end points. Both the Atomos Plugin and Atomos Theme contain a file called routes.php. This is where you can define all of your routes.

Route Prefixes

Because WordPress utilises permalinks for front end requests with its own routing. It’s highly recommended you set a prefix for your routes. This can be done at the top of the file by using the following.
Example:
$route = route()->prefix('custom-prefix');
You’ll more than likely find this code already exists if you’re setting up a new site.

Routing GET & POST

You can now use $route->get() or a $route->post() to direct relevant request methods. The first parameter of both post & get is the URL you want to route. The second parameter is the controller method or closure function you want to use to handle the request.
Example with controller
$route->get('foo','FooBarController@foo');
$route->post('foo/bar','FooBarController@bar');
The controllers that routes use live in the Controllers directory. Anything after the @ symbol is the method on that controller.
Example with closure function
$route->get('foo', function(){
  $message = 'hello world';
  return view('say-hello',[
    'message'=>$message
  ]);
});

Views

Views are where you should keep your front-end HTML to keep it separate from your controller logic. This follows the standard MVC Pattern that is used throughout many frameworks and well-structured applications.
Views are in the top-level Views directory. All views should be PHP files.

Available Parameters
view(string $name, array $properties)
Available Parameters
return view('Foo/Bar');

Notice you don’t need to put the .php extension on the file name for the first parameter. You can simply pass the directory and file name.

Passing Properties

You can also pass properties into your view via the second parameter as an associative array. Array keys will be available in the view as a variable.
Example:
return view('Foo/Bar', [
  'name'=>'Jason',
  'age'=>'25'
];
Remember, the properties will be available in the view file as variables. So the above will pass the variables to a view like so:
Example:
<html>
 <body>
  <p>Hello, I am <?= $name ?> and I am <?= $age ?> years old.</p>
 </body>
</html>

Configurations

Configuration files are the perfect place to put configurable data that you want to easily access throughout your project. You can find the configuration files at the top-level Config folder. Every config file in here will be registered when your plugin or theme boots.

Your configuration files should return an array format. This allows the config helper to access your configurations via dot notation.

Example:
return [
  'version' => '1.0.0',
  'name' => 'atomos',
  'contact'=>[
   'emai'=>'jason@example.com',
   'name'=>'jason'
 ]
]

Retrieving Configurations

Available parameters
config(string $name)
Example:
config('defaults.version'); //will return '1.0.0'
config('defaults.contact.email') //will return 'jason@example.com'
By default, there is a Boot.php file within your Config folder. This is a useful config to boot your own helpers and providers. You will also find a Enqueue.php file for enqueueing scripts. Please see the enqueue section to learn more.

Option Pages

With Atomos you can create an option page quickly and easily with the fluid page helper function.

Creating page

To create a page, simply use parent() method followed using the create() method.
Available Parameters
page()->parent(string $name, string $view, array $viewProperties, array $options(WP))->create()
Example:
page()->parent('Site Settings', 'Admin/Settings')->create();

Creating a sub page

You can then continue to make sub pages for the top level page by using the ->sub() method like so:
Available Parameters
->sub(string $name, string $view, array $viewProperties, array $options(WP))
Example:
page()->parent('Site Settings', 'Admin/Settings')
->sub('Licence', 'Admin/Licence')
->create();

Using a Controller

As explained in the controller’s section about contructor injection. You can just pass the first property to the ->parameter() method and then call the ->useController() method to pass the work into a controller. An instance of the page will be injected into the constructor.
Example:
page()->parent('Site Settings')->useController('SettingsController@show');

Creating page fields

A huge benefit to using Atomos to create your option pages is that it can also generate your option fields using the ->field() method.
Available Parameters
->field(string $type, string $name, string $label, array $options)
Example:
page()->parent('Plugin Page')
 ->field('text', 'name', 'Your Name')
 ->field('number', 'age', 'Enter Age', [
  'min' => 1,
  'max' => 120,
  'step' => 1
 ])
 ->field('select', 'gender', 'Select Gender', [
  'male' => 'Male',
  'female' => 'Female',
  'other' => 'Other'
 ])
 ->create();

Retrieving Page Fields

After setting up the fields on your options page. You'll more than likely want to retrieve the values elsewhere in your code. You can simply use WordPress's own get_option() function to achieve this.
Example:
//If the field was defined like so:
page()->parent('Example Settings')
  ->field('text', 'name', 'Your Name')
  ->create();

//You'll retrieve the value like this:
get_option('example-settings-name');
If you have you environment set to DEV or LOCAL via the ATOMOS_ENV constant in your wp-config.php file. You'll be able to see snippets on how to retrieve your values. Please see the Installation Section on how to do this. The option name is usually the set value, lower-cased and prefixed with the page slug.

Inputs (requests)

You can retrieve POST & GET requests with a useful input helper. The input helper has quite a few benefits over using the standard $_POST & $_GET methods.

Retrieving all inputs

You can easy retrieve all inputs as well.
Example:
$inputs = input()->all(); 

Retrieving Inputs

The first parameters will be the name of the input you wish to retrieve. The second parameter is the default value if the requested input value doesn’t exist.
Example:
$input = input('name', 'unknown'); 
Alternatively, you if you want, you can use the ->get() method. Both achieve the same results. The above is just shorthand.
Example using ->get() method
$input = input()->get('name', 'unknown'); 

Excluding Inputs

Available Parameters
input()->without(mixed $inputs)
Example:
//All without single input
$all = input()->without('token');

//All without multiple inputs
$all = input()->without(['token', 'email', 'password']);

Input Has

You can easily check if a required input exists by using the ‘has’ method.
Available Parameters
input()->has(mixed $name);
Example:
If(input()->has('name')){
 $name = input()->get('name');
}

Validation

Validation on a user’s data is an important part of any PHP and WordPress site. Validating data has been made simple with the ‘validator’ helper.

Setting Validation Rules

You can validate any type of data with a validator. As long as it's in an associative array format. A common use would be to pass in inputs->all() to validate a users (request) input. You can set the validation rules in with the ->rules() method. The key of each rule must match the key of the data you wish to validate against. You can have multiple validation rules for each piece of data, just separate the rules with a comma. If the rule requires a property; such as minimum or maximum, you can use a colon after the rule to attach the property.
Availale Parameters
validator(array $data)->rules(array $rules);
Example:
//Set data
$data = [
 'name'=>'Jason',
 'age'=>21,
 'email'=>'jason@test.com'
];

//Set rules
$rules = [
 'name'=>'required',
 'age'=>'required, numeric, min:18, max:30',
 'email'=>'required, email'
];

//Set validator
$validator = validator($data)->rules($rules);

Validating Data

Once you’ve set the validation rules, you can easily validate the data.
Example:
if($validator->validate()){
  return 'All data is valid';
}

Getting Validation Errors

If your validation fails. You can check if errors exist and then retrieve the validation errors.
Example:
if($validator->hasErrors()){
  $errors = $validator->getErrors();
}

Setting Custom Validation Messages

Sometimes you want to set your own validation error messages. Just add to the rules with a pipe separator.
Example:
//Set rules
$rules = [
  'email'=>'required, email | Your email address is required.',
  'name'=>'required | Name is required.',
  'age'=>'number, min:18 | Age should be a number only, you must also be 18 to enter.',
];

//Validate
$validator = validator($data)->rules($rules);
You can also use variable to put the field name in the message with using {field}
Example:
//Set rules
$rules = [
  'email'=>'required, email | {field} is required.',
];

//Validate
$validator = validator($data)->rules($rules);

Available Validation Rules

Here are a list of available validation rules:  
  • required - Field is required
  • equals - Field must match another field (email/password confirmation)
  • different - Field must be different than another field
  • accepted - Checkbox or Radio must be accepted (yes, on, 1, true)
  • numeric - Must be numeric
  • integer - Must be integer number
  • boolean - Must be boolean
  • array - Must be array
  • length - String must be certain length
  • lengthMin - String must be greater than given length
  • lengthMax - String must be less than given length
  • min - Minimum
  • max - Maximum
  • in - Performs in_array check on given array values
  • notIn - Negation of in rule (not in array of values)
  • ip - Valid IP address
  • email - Valid email address
  • emailDNS - Valid email address with active DNS record
  • url - Valid URL
  • urlActive - Valid URL with active DNS record
  • alpha - Alphabetic characters only
  • alphaNum - Alphabetic and numeric characters only
  • slug - URL slug characters (a-z, 0-9, -, _)
  • regex - Field matches given regex pattern
  • date - Field is a valid date (US format)
  • dateFormat - Field is a valid date in the given format (use for other formats)
  • dateBefore - Field is a valid date and is before the given date
  • dateAfter - Field is a valid date and is after the given date
  • contains - Field is a string and contains the given string
  • creditCard - Field is a valid credit card number
Atomos's validation is an implementation of https://github.com/vlucas/valitron however, some validation rules have been ommited from Atomos as they do not fit into our implemention.
Example of tying multiple rules together
//Set data
$data = [
  'name'=>'Jason',
  'name2'=>'Jason2',
  'age'=>26,
  'email'=>'jason@atomosframework.com',
  'DOB'=>'27/02/1992',
  'movies'=>['Toy Story', 'Interstellar', 'Oblivion'],
  'subscribed'=>true
];

//Set rules
$rules = [
  'name'=>'required, alpha, lengthMax:10, different:name2',
  'age'=>'required, min:18, max:30',
  'email'=>'email',
  'DOB'=>'dateFormat:d/m/Y',
  'movies'=>'array',
  'subscribed'=>'boolean'
];

//Validate
$validator = validator($data)->rules($rules);
$result = $validator->validate();

//Determine restuls
if($result){
  #success code here...
}

Enqueueing

WordPress already has a good system for enqueuing your scripts and styles. But to keep things consistent and easy, Atomos comes with its own flavour on enqueuing in a more readable format.

Enqueue From Config

The easiest way to add styles and scripts to your WordPress project is to use the enqueue config files located at Config/Enqueue.php. You will see 3 config areas that you can add your styles and scripts to. Admin (dashboard), Frontend (your site), All (all areas). By default each file you add to the array will look in your assets folder.
Example:
'frontend'=>[
  //Styles
  'styles'=>[
   'css/styles.css',
   'css/defaults.css'
  ]

  //Scripts
  'scripts'=>[
   'js/scripts.js'
  ]
],

Enqueue Script

To enqueue a script from your theme you can simply call the script helper.
Example:
script()->theme()->add('js/my-script.js');
By default when using the ->theme() method the script or style will load from your /assets folder. If you wish to load your own directory, simply use the ->baseUrl() method instead of the ->theme().
Example:
script()->baseUrl(plugin_directory().'/custom_assets')->add('css/my-style.css');

Enqueue Style

To enqueue a script from your theme you can simply call the style helper.
Example:
style()->theme()->add('css/my-style.css');
By default when using the ->theme() method the script or style will load from your /assets folder. If you wish to load your own base URL, simply use the ->baseUrl() method instead of the ->theme().
Example:
style()->baseUrl(plugin_url().'/custom_assets')->add('css/my-style.css');

Navigation Helper

WordPress’s menus are a brilliant and a very useful feature. To make it easier Atomos has a handy helper that you can use to get a simple multi-dimensional array of the navigation and sub navigation items. This allows you to write your navigation menus the way you want in your views.

Available Parameters:
nav()->items(int $menu_id);
Example:
nav()->items(2);
Results:

[

  768 =>  [

   "id" => 768,

   "title" => "About",

   "post_title" => "",

   "target" => "",

   "url" => "http://atomosframework.com/about,

   "menu_order" => 1,

   "active" => false,

   "has_sub_items" => true,

   "sub_items" => [

    0 => [

     "id" => 774,

     "title" => "Features",

     "post_title" => "",

     "target" => "",

     "url" => "http://atomosframework.com/about/features",

     "menu_order" => 2,

    ],

    2 => [

     "id" => 775,

     "title" => "Ease Of Use",

     "post_title" => "",

     "target" => "",

     "url" => "http://atomosframework.com/about/easy-of-use",

     "menu_order" => 3,

    ]

   ]

  ]

]

A few key benefits of using this function is that you get the sub items of a menu in the same array. You can also see that there is an active key. This indicates if the page you’re on is the same as the navigation item. If so, it’ll be active.

Post Types

To create a custom post types you can use the Atomos implementation of the WordPress post types.

Create Post Type

To create a post type, just use the verbose code below. Note, you don’t have to pass options (second parameter) to the create method. But if you want to overwrite the WordPress options you can pass the options you desire from the WordPress post type documentation.
Available Parameters:
postType()->create(string $name, array $options(WP))
Example:
postType()->create('Site Slides', [
  'public' => true,
  'has_archive' => true
]);

Get All Post Types

You can easily grab all set post types by using the ->all() method. Please note, you can only use this method to retrieve custom post types after the WordPress ‘init’ action has been triggered.
Example:
postType()->all()
This will return an array of all post types.

Labels

Setting labels is an important part of creating post types, so Atomos has provided a fluid method you can use before calling the ->create() method that will set the labels for you.
Available Parameters
postType()->labels(array $labels)->create(string $name, array $options(WP))
Example:
postType()->labels([
  'new_item'=>'New Slide',
  'edit_item'=>'Edit Slide'
])->create('Site Slides');
You can view all available labels in the WordPress documentation.

Find A Post Type

Finding a custom post type is just as easy as creating, just use the ->find() method. You must use the ->get() method after to get the results.
Available Parameters
postType()->find(string $name)
Example:
postType()->find('Site Slides')->get();

Taxonomy

You’ll find the taxonomy helper very similar to the post type helper. Again it’s an Atomos implementation of the WordPress Taxonomy.

Create Taxonomy

To create a taxonomy, just use the verbose code below. Note, you don’t have to pass options (second parameter) to the create method. But if you want to overwrite the WordPress options you can pass the options you desire from the WordPress taxonomy documentation.
Available Parameters
taxonomy()->create(string $name, array $options(WP))
Example:
taxonomy()->create('Product Categories', [
  'hierarchical'=> true,
  'show_ui' =>true
]);

Labels

Like post types, you can set labels on a taxonomy with a fluid method. You can use it before calling the ->create() method.
Available Parameters
taxonomy()->labels(array $labels)->create(string $name, array $options(WP))
Example:
taxonomy()->labels([
  'new_item'=>'New Category',
  'edit_item'=>'Edit Category'
])->create('Product Category');
You can view all available labels in the WordPress documentation.  

Get All Taxonomies

Like post types, you can easily grab all taxonomies by using the ->all() method. Please note, you can only use this method to retrieve custom taxonomies after the WordPress ‘init’ action has been triggered.
Example:
taxonomy()->all()
This will return an array of all taxonomies.

Find A Taxonomy

To find a taxonomy, just use the ->find() method. You must use the ->get() method after to get the results.
Available Parameters
taxonomy()->find(string $name)
Example:
taxonomy()->find('Product Category')->get();

Users

Atomos users is an implementation of WordPress users.

Current User

You can grab currently logged in user by using the ->current() method. You can then use the ->get() method to get the found WP user object. If no user is logged in, it’ll return null.
Example:
users()->current()->get()

All Users

To grab all available users. Just use the ->all() method. This will return an array of all WP user objects.
Example:
users()->all()

Find A User

There are 3 simple ways on how to find a user, by ID, Email or Username. Pass anyone of these 3 into ->find() to try and find the user followed by the ->get() method to retrieve the user.
Available Parameters
users()->find(string $parameter)
Example:
//Find by ID
users()->find(2)->get();

//Find  by email
users()->find('jason@example.com')->get()

//Find by username
users()->find('jasonk')->get()

Updating A User

Because the user helper is a fluid API. You can call update after either ->current() or ->find(). You can use all of the available WordPress update parameters.
Available Parameters
users()->find(string $parameter)
Example:
//Update current user
users()->current()->update([
  'role'=>'editor',
  'email'=>'jason@example.com',
  'first_name'=>'jason'
]);

//Update found user
users()->find('jasonk')->update([
  'role'=>'editor',
  'email'=>'jason@example.com',
  'first_name'=>'jason'
]);

Deleting A User, Reassigning Posts

As WordPress assigns all posts to a user, to delete the posts you have 2 options. Delete all associated posts or reassign them. To delete the user with all associated posts, just call ->delete() after you find a user. If you want to reassign, make sure you call ->assignPostsTo() before calling the ->delete() method. assignPostsTo() uses the same parameters as ->find().
Available Parameters
users()->assignPostsTo(string $parameter)->delete()
Example:
//Delete user with all the users posts.
users()->find('jasonk')->delete();

//Delete user and assign the users post to a new user.
users()->find('jasonk')->assignPostsTo('stephp')->delete();

Getting A Users Posts

After you find a user you can easily retrieve all of there posts for that user by using the ->posts() method.
Example:
//Get a users posts
users()->find('jasonk')->posts();

The Container

Like any good PHP framework, Atomos is based on a basic inversion of control (ioc) container. The container allows you to switch out dependency (classes) implementations and register some core directories. Out of the box the container is ready to go. 

Binding A Class

Adding a class to the container will allow you to call a class with an aliased name throughout your project, allowing you to switch implementation if ever required. The easiest way to achieve this is in the your plugin in the Config/Bindings.php file or Project/Config/Binding.php for you theme. 
Example:
'MyNavigationClass' => 'My\Plugin\Classes\Repositories\NavigationRepository'

Binding A Class Manually

Adding a class to the container will allow you to call a class with an aliased name throughout your project, allowing you to switch implementation if ever required. To add a class simply call the ->bind() method. It’s recommended you add classes to the container on boot or before doing any plugin/theme logic.   Note: you can use add(), bind() or register() to achieve this. In this example we’ll use bind().
Available Parameters
container()->bind(string $alias, string $class) 
Example:
container()->bind('MyNavigationClass', 'My\Plugin\Classes\Repositories\NavigationRepository')

Retrieving A Class

After a class has been registered into the container, you’ll want to retrieve it later on. To do so, just use the ->resolve() method.  Note: you can use resolve(), get(), make() to achieve this. In this example we will use resolve(). 
Available Parameters
container()->resolve(string $alias, string $class) 
Example:
container()->resolve('MyNavigationClass') 

Check If A Class Exists

You can check if a class exists in the container by just using the ->has() method. 
Available Parameters
container()->has(string $alias) 
Example:
if(container()->has('MyNavigationClass')){
  $class = container()->resolve('MyNavigationClass');
}

Register Configuration Directory

If you have a desire to move or register another configuration directory, you can do so with the ->registerConfigDirectory() method. It’s recommended you prefix with a unique array namespace in the config files. Hint: a great place to do this is in a provider, providers are covered in the providers section.
Available Parameters
container()->registerConfigDirectory(string $directory) 
Example:
container()->registerConfigDirectory('App/Module/Configs'); 

Register View Directory

If you want to register your own view directories. Just use the ->registerViewDirectory() method.  
Available Parameters
container()->registerViewDirectory(string $directory) 
Example:
container()->registerViewDirectory('App/Module/Views'); 

Register Controller Namespace

Controller call backs are used within few functions and patterns within Atomos. So being able to register a controller namespace can prove useful. You can easily call the ->registerControllerNamespace() method. 
Available Parameters
container()->registerControllerNamespace(string $namespace)  
Example:
container()->registerControllerNamespace('App/Module/Controllers'); 

Providers

Providers are used to register code on boot. They are primary used to load hooks. 

Register New Provider

You can register a provider in Config/Boot.php. Simply add the providers class namespace to the providers array.  Your provider class must have a boot method and should extend the ServiceProvider class in your plugin/themes root directory. You can find a default providers file in the Providers folder to start you off.   Note: Making your class implement the Atomos\Core\Interfaces\ProviderInterface can help make your provider conform to using the correct methods. 
Example:
class CustomServiceProvider extends ServiceProvider implements ProviderInterface
{
  /**
  * Boot
  * Use this method to load any code you need to load on boot.
  */
  public function boot()
  {
   //Your code here
  }
} 

Add Actions & Filters

Because the core service provider class contains a lot of helper methods. These will be available in your own providers. Here’s how to use the action & filter methods. 
Example:
public function boot()
{
  //Action via closure
  $this->action('init', function(){
   //Code here…
  });

  //Action via class
  $this->action('init', [(new Users),'registerRoles']);

  //Filters via closure
  $this->filter('admin_footer_text', function($value){
   //Code here…
  });

  //Filters via class
  $this->filter('admin_footer_text', [(new TextReplacements),'footerText']);
} 

Enqueue Styles & Scripts

You can easily enqueue custom styles and scripts within a provider class as well. Infact, if you find that the enqueue config files doesn’t give you the flexibility needed. A provider is the perfect place to do it. 
Example:
public function boot()
{
  //Enqueue login scripts
  $this->style()->add('general.css','custom-styles');

  //Enqueue login styles
  $this->style()->loginOnly()->add('login.css','custom-login');

  //Enqueue login script
  $this->script()->add('script.js','custom-scripts');
} 

Pages

One of the best places to register admin pages and create fields on boot is in a service class. Using the $this->page() method will give you access to all the standard page methods for adding pagessub pages & fields. You will see a dedicated folder and example provider class for adding pages in Providers/Pages. Please see the Admin Pages section for more information. 
Example:
public function boot()
{
  page()->parent('Plugin Page')
   ->field('text', 'name', 'Your Name')
   ->field('number', 'number', 'Select Number', [
    'min' => 1,
    'max' => 10,
    'step' => 2
   ])
   ->field('select', 'select', 'Select Something', [
    'test' => 'Test',
    'test2' => 'Test2',
   ])
   ->create();
} 

Other Available Methods

You can access the majority of container methods via the service container class as well, such as add(), bind(), make(), resolve() and get(), depending on your preference. 

Sessions

As sessions are a fundamental part of WordPress & PHP in general. Atomos includes a handy sessions helper.

Set Session

If you want to set a new session item. You simply pass it a name and a value as the 2 available parameters.
Available Parameters
session()->set(string $name, $value)
Example:
session()->set('applicants_name', 'Stephanie Payne');

Get Session

Getting a session value after it’s set is can be done in two ways, please see the examples below.
Available Parameters
session()->get(string $name) or session(string $name)
Example:
session()->get('applicants_name'); //Stephanie Payne
Example 2
session('applicants_name'); //Stephanie Payne

Forget Session

You can tell the session to forget a value by calling the ->forget() method. This will forget the value instantly. This will return void.
Available Parameters
session()->forget(string $name)
Example:
session()->forget('applicants_name');

Getting All Sessions

Getting all the sessions as an array is done by calling the ->all() method on the helper. Example:
Example:
session()->all(); ­­­­ //Will return an array of values.
You can also get all set sessions without a certain item by calling ->without() instead of ->all()
Available Parameters
session()->without(string $name)
Example:
session()->without('last_name'); ­­­­ //Will return an array of values without the desired value.

Session Has

You may want to do some conditional logic to see if a session exists. You can simply use the ->has() method to achieve this. It will return a boolean.
Available Parameters
session()->has(string $name)
Example:
if(session()->has('applicant_name')){
  //Your code
}

Session Flash

You can force a session to only be available once. The session will set and once retrieved, it will be unset. This is known as a session flash.
Available Parameters
session()->flash(string $name)
Example:
Example:
//Set the flash
session()->flash('success-messages', 'You have successfully applied online.');

//If session is available. Show it.
if(session()->has('success-message')){
  echo session()->get('success-message');
}
You can use this for displaying success messages and more.

Excluding Sessions

If you want to exclude some session keys from retrieving all sessions. Just use the ->without method. Parameters:
Available Parameters
session()->without(string or array $name)
Example:
//Get all set sessions, without the token.
$all = session()->without('token');

//Get all set sessions, without the token or password.
$all = session()->without(['token','password']);

Something

AppKit Theme

Title

Content...