Code Monkey home page Code Monkey logo

laravel-config-validator's Introduction

Ash Allen - Laravel web developer

Hey, I'm Ash Allen! ๐Ÿ‘‹

I'm a freelance Laravel web developer from Preston, UK

  • ๐Ÿ’ฅ I build systems and websites for small businesses using Laravel.
  • ๐Ÿ“š I have a blog that focuses on helping other developers learn more about Laravel, PHP and web development.
  • ๐Ÿ–ฅ I have contributed to Laravel and other open-source projects.
  • ๐ŸŽ‰ I currently have 5 Laravel packages that are being used in commercial systems.
  • โœ๏ธ I write about Laravel, PHP and other web developments topics on the Ash Allen Design blog.
  • โœจ I wrote the FREE 70-page ebook called The Clean Coder's Guide to Laravel.
  • โšก I'm open to collaborating on other Laravel projects.
  • ๐Ÿฅ… 2022 Goal: Contribute to more open-source projects and write a new e-book.

I Write Guest Blog Posts

I Was Featured on Laravel News!

Languages and Tools

Laravel

Vue JS

HTML5

CSS3

Sass

JavaScript

SQL

MySQL

Git




โšก My Open Source Projects


๐Ÿ“˜ Some of My Blog Posts


codeSTACKr's Github Stats

laravel-config-validator's People

Contributors

ash-jc-allen avatar kohenkatz avatar laravel-shift avatar stylecibot avatar sy-dante avatar xico2k avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

laravel-config-validator's Issues

Add an environment toggle

There might be times when we only want rules to be run in specific environments.

As an example, we might want to use stricter rules in production rather than local.

Missing rules

Is it possible to thow an exception on missing validation rules. This ensures that all keys have some validations set and that not keys have been added accidentaly that have no rules set

Pass in the config rule path

At the moment, the config validator will automatically search the config/validation folder for validator files. It might be useful to be able to pass in a folder path for anyone who wants to put their validation files in a different location.

Alternative config storage

Hi! First of all I want to say thanks so much your job and this package.
I have a problem with path configuration data.
By default laravel storage data 'config' path, it's ok for everyone, but in my case complicated.
I want to set data another path
For example 'app/Configuration/...'
I suggest changing hydrateConfigValueArray or another part codes.
Inject some interface for storing configuration data, which knows how get any values.
What do you think about this thought?
I will make PR, if you like this idea.

disable config validator temporary

I get errors by start run Laravel Dusk in a local environment
Is there a possibility to deactivate config validator temporary without remove from composer.json?
Or Did I have configure dusk ?

The config is correct but changed while dusk runs
$php artisan dusk Environment modified. Restarting server... .... Environment modified. Restarting server...

failure-Tests_Browser_DebugTest_testRidirect-0

Write tests

PHPUnit tests will need to be written for the package.

Add a command to create validation files

It would be nice to have a command that creates the layout validation file for you.

As an example, we could maybe something along the lines of the following to create a validation file for config/auth.php:

php artisan config:make-validation auth

This could create a config/validation/auth.php file with the following contents:

<?php

use AshAllenDesign\ConfigValidator\App\Services\Rule;

return [
    Rule::make('')->rules([]),
];

Add custom messages for the validation rules

Provide the option to pass custom messages into the Rule object when building it. This might be needed in places where developers don't want to rely on the default Laravel validation messages.

Add a command for validating the config

It would be nice to have a command which can be run to validate the config quickly.

Maybe something along the lines of:

php artisan config:validate

We could maybe extend this to only validate certain config files. For example, to validate the auth.php config file, we could run something like:

php artisan config:validate --config=auth

Crash when config value should be an array

In my application config, I have a config item that needs to be an array of values, with at least one value in it:

'names' => array_filter(explode(',', env('NAMES', ''))),

I wanted to create a validation rule for it like this:

Rule::make('migrate_from')->rules(['array', 'min:1']),

When I run config:validate, I get this exception:


   Illuminate\View\ViewException 

  htmlspecialchars(): Argument #1 ($string) must be of type string, array given (View: /path/to/app/vendor/ashallendesign/laravel-config-validator/resources/views/validate-config.blade.php)

  at /path/to/app/vendor/illuminate/support/helpers.php:119
    115โ–•         if ($value instanceof Htmlable) {
    116โ–•             return $value->toHtml();
    117โ–•         }
    118โ–•
  โžœ 119โ–•         return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8', $doubleEncode);
    120โ–•     }
    121โ–• }
    122โ–•
    123โ–• if (! function_exists('env')) {

  1   /path/to/app/vendor/illuminate/view/Engines/PhpEngine.php:60
      Illuminate\View\Engines\CompilerEngine::handleViewException(Object(TypeError))

  2   /path/to/app/vendor/illuminate/support/helpers.php:119
      TypeError::("htmlspecialchars(): Argument #1 ($string) must be of type string, array given")

I traced this to this line in the view:

<b>{{ config($configField) }}</b>

To make it work, I replaced that line with this:

<b>{{ json_encode(config($configField, JSON_PRETTY_PRINT)) }}</b>

I'm not sure whether my fix is a good way to do it (and I would submit it as a PR), or whether there is a better way. On one hand, this way will always work and will show a nice output for all kinds of config values (including simple and associative arrays). On the other hand, it changes how regular string values appear (by putting quotes around them).

Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.