2017 © Pedro Peláez
 

library themosis-illuminate

A themosis plugin that implements the illuminate/cache packing with a WP_Object_Cache driver

image

djgadd/themosis-illuminate

A themosis plugin that implements the illuminate/cache packing with a WP_Object_Cache driver

  • Sunday, April 22, 2018
  • by djgadd
  • Repository
  • 1 Watchers
  • 2 Stars
  • 93 Installations
  • PHP
  • 7 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 17 Versions
  • 9 % Grown

The README.md

Themosis Illuminate

A package for the Themosis framework that implements various Illuminate packages, some replace the Themosis packages (such as config and validator.) Also loads in most of Laravel's helper functions (see below.), (*1)

Install

Install through composer: - composer require keltiecochrane/themosis-illuminate, (*2)

See below for how to activate the individual packages., (*3)

Packages

The following packages have been implemented: -, (*4)

Config

To use the config (which we recommend as it implements ArrayAccess which is required by most of the package implementations here) you'll need to replace Themosis' Service Provider and Facade. It's API compatible but implements additional features (it seems likely Themosis will eventually move to the Illuminate package in the future too.) Also allows config files to be extended, which is useful in parent/child scenarios., (*5)

Activation

Add the service provider to your theme/resources/config/providers.config.php: - KeltieCochrane\Illuminate\Config\ConfigServiceProvider::class,, (*6)

Replace the facade in your theme/resources/config/theme.config.php: - 'Config' => KeltieCochrane\Illuminate\Config\ConfigFacade::class,, (*7)

Note: You don't necassarily have to add the facade at this moment, as it effectively does the same thing that the Themosis facade, but it's worth adding in case we need to make any changes in line with the Illuminate facade in the future., (*8)

Examples

Use at you normally would, e.g.: -, (*9)

  // Normal usage
  Config::get('something');

  // Setting a default
  Config::get('theme.locale', 'en-GB');

  // Using ArrayAccess
  app('config')['theme.locale'];

Filesystem

The filesystem is required by Translation and Validation, but is a useful feature to have anyway., (*10)

Activation

Copy the filesystem.config.php file to your theme/resources/config folder, some defaults have been setup for you., (*11)

Add the service provider to your theme/resources/config/providers.config.php: - KeltieCochrane\Illuminate\Filesystem\FilesystemServiceProvider::class,, (*12)

Optionally add the facades in your theme/resources/config/theme.config.php: -, (*13)

  'File' => KeltieCochrane\Illuminate\Filesystem\FileFacade::class,
  'Storage' => KeltieCochrane\Illuminate\Filesystem\StorageFacade::class,

Examples

  // Get an array of files in the current directory
  File::files(__DIR__);

  // Make a file in the current directory
  File::put(__DIR__.DS.'file.txt', 'Contents');

  // Put a file in your 'storage' directory
  Storage::disk('local')->put('file.txt', 'Contents');

  // Check if a file exists in your theme's 'dist' directory
  Storage::disk('dist')->exists('css/app.css');

  // Get a file url in your theme's 'dist' directory
  Storage::disk('dist')->url('css/app.css');

See the Laravel docs for more info., (*14)

Mail

Mail is optional and not required by anything else, but is a nicer way of sending emails than through WordPress. A wp_mail Transport is provided and is used by default, so if your WordPress instance can send mail so can the Mail service., (*15)

Activation

Copy the mail.config.php file to your theme/resources/config folder, configure as appropriate., (*16)

If you're going to be using an external service such as MailGun or SparkPost you'll need to add the following to your theme/resources/services.config.php (you may need to create this file if you haven't already got one): -, (*17)

  'mailgun' => [
      'domain' => env('MAILGUN_DOMAIN'),
      'secret' => env('MAILGUN_SECRET'),
  ],

  'ses' => [
      'key' => env('SES_KEY'),
      'secret' => env('SES_SECRET'),
      'region' => 'us-east-1',
  ],

  'sparkpost' => [
      'secret' => env('SPARKPOST_SECRET'),
  ],

Add the service provider to your theme/resources/config/providers.config.php: - KeltieCochrane\Illuminate\Mail\MailServiceProvider::class,, (*18)

Optionally add the facades in your theme/resources/config/theme.config.php: - 'Mail' => KeltieCochrane\Illuminate\Mail\MailFacade::class,, (*19)

Examples

  // Send an email
  Mail::send('mail.welcome', ['with' => 'Some data for the view.'], function ($mailer) {
    $attachmentPath = Storage::disk('dist')->getDriver()->getAdapter()->getPathPrefix().'images/call-icon.svg';

    $mailer->to('someone@somecompany.tld')
      ->bcc('mailbin@somecompany.tld')
      ->subject('Subject')
      ->attach($attachmentPath);
  });

See the Laravel docs for more info., (*20)

Translation

Translation requires Filesystem to be loaded in and is required by Validation., (*21)

Activation

Add the service provider to your theme/resources/config/providers.config.php: - KeltieCochrane\Illuminate\Translation\TranslationServiceProvider::class,, (*22)

Optionally add the facades in your theme/resources/config/theme.config.php: - 'Lang' => KeltieCochrane\Illuminate\Translation\LangFacade::class,, (*23)

Files

You can add translations from the Laravel, you'll need to add them to your theme/resources/lang folder, the only one worth copying for now is the validation file (if indeed you're using validation.) You can of course create your own files to add translation throughout your site, but we'd still recommend using a translation plugin., (*24)

Examples

  // Is there a translation available in 'file' under 'key'
  Lang::has('file.key');

  // Is there a translation under the 'it' locale for 'file' under 'key'
  // Refuse to use the fall back locale
  Lang::has('file.key', 'it', false);

  // Get the translation
  Lang::trans('file.key');

  // Get the translation and replace some text in it
  Lang::trans('file.key', ['name' => 'John']);

  // Get the 'it' translation and replace some text in it
  // Refuse to use the fall back locale
  Lang::trans('file.key', ['name' => 'John'], 'it', false);

See the Laravel docs for more info., (*25)

Validation

Validation requires Translation and Filesystem. It replaces the built in Themosis Validator (if you use the facade) which is more of a sanatiser than a validator. The Validator has been extended with a valid_nonce rule that can be used to verify a nonce., (*26)

Activation

Add the service provider to your theme/resources/config/providers.config.php: - KeltieCochrane\Illuminate\Validation\ValidationServiceProvider::class,, (*27)

Add the facades in your theme/resources/config/theme.config.php: - 'Validator' => KeltieCochrane\Illuminate\Validation\ValidatorFacade::class,, (*28)

Examples

  $validator = Validator::make($request->all(), [
    'title' => 'required|max:255',
    'body' => 'required',
    'nonce' => 'valid_nonce:action',
  ]);

  if ($validator->fails()) {
    return view()->with([
      'errors' => $validator->errors(),
    ]);
  }

See the Laravel docs for more info., (*29)

Helpers

The following (additional) helpers are available: -, (*30)

  • array_add
  • array_collapse
  • array_divide
  • array_dot
  • array_first
  • array_flatten
  • array_forget
  • array_has
  • array_last
  • array_only
  • array_pluck
  • array_prepend
  • array_pull
  • array_sort
  • array_sort_recursive
  • array_where
  • array_wrap
  • camel_case
  • class_basename
  • class_uses_recursive
  • collect
  • config
  • data_fill
  • data_get
  • data_set
  • ends_with
  • env
  • head
  • kebab_case
  • last
  • object_get
  • preg_replace_array
  • retry
  • request
  • snake_case
  • str_finish
  • str_limit
  • str_plural
  • str_random
  • str_replace_array
  • str_replace_first
  • str_replace_last
  • str_singular
  • str_slug
  • studly_case
  • tap
  • title_case
  • trait_uses_recursive
  • trans
  • trans_choice
  • validator
  • windows_os

See the Laravel docs for more info., (*31)

Todo

  • Tests - a lot of this is trusting in the Laravel packages and Themosis behaving themselves
  • Add more packages
  • Possibly merge Cache and Logger into this so there's one package to rule them all

Support

This package is provided as is, though we'll endeavour to help where we can., (*32)

Contributing

Any contributions would be encouraged and much appreciated, you can contribute by: -, (*33)

  • Reporting bugs
  • Suggesting features
  • Sending pull requests

The Versions

08/03 2017

0.1.0

0.1.0.0

A themosis plugin that implements the illuminate/cache packing with a WP_Object_Cache driver

  Sources   Download

The Requires

 

plugin themosis

08/03 2017

dev-release/0.1.0

dev-release/0.1.0

A themosis plugin that implements the illuminate/cache packing with a WP_Object_Cache driver

  Sources   Download

The Requires

 

plugin themosis

06/03 2017

0.0.1

0.0.1.0

A themosis plugin that implements the illuminate/cache packing with a WP_Object_Cache driver

  Sources   Download

The Requires

 

plugin themosis

06/03 2017

dev-release/0.0.1

dev-release/0.0.1

A themosis plugin that implements the illuminate/cache packing with a WP_Object_Cache driver

  Sources   Download

The Requires

 

plugin themosis