Skip to content

Commit

Permalink
Initial build
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Jul 18, 2016
0 parents commit 93248b0
Show file tree
Hide file tree
Showing 21 changed files with 1,732 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
/vendor
composer.phar
composer.lock
.DS_Store
9 changes: 9 additions & 0 deletions .styleci.yml
@@ -0,0 +1,9 @@
preset: recommended

risky: false

linting: true

finder:
exclude:
- "tests"
12 changes: 12 additions & 0 deletions .travis.yml
@@ -0,0 +1,12 @@
language: php

php:
- 5.5
- 5.6
- hhvm

before_script:
- travis_retry composer self-update
- travis_retry composer install --prefer-source --no-interaction --dev

script: phpunit
81 changes: 81 additions & 0 deletions README.md
@@ -0,0 +1,81 @@
# FormMaker

**FormMaker** - A remarkably magical form maker tool for Laravel.

The FormMaker package provides a set of tools for generating HTML forms with as little as 1 line of code. Don't want to write boring HTML, neither do we. The FormMaker will generate error containers, all fields defined by either the table or object column types, or if you prefer to have more control define a config.

##### Author(s):
* [Matt Lantz](https://github.com/mlantz) ([@mattylantz](http://twitter.com/mattylantz), matt at yabhq dot com)
* [Chris Blackwell](https://github.com/chrisblackwell) ([@chrisblackwell](https://twitter.com/chrisblackwell), chris at yabhq dot com)

## Detailed Documentation
Please consult the documentation here: [http://laracogs.com/docs/Utilties/FormMaker](http://laracogs.com/docs/Utilties/FormMaker)

## Requirements

1. PHP 5.6+
2. OpenSSL
3. Laravel 5.1+

----

### Installation

Start a new Laravel project:
```php
composer create-project laravel/laravel your-project-name
```

Then run the following to add FormMaker
```php
composer require "yab/formmaker"
```

Add this to the `config/app.php` in the providers array:
```php
Yab\FormMaker\FormMakerProvider::class
```

Time to publish those assets!
```php
php artisan vendor:publish --provider="Yab\FormMaker\FormMakerProvider"
```

##### After these few steps you have the following tools at your fingertips:

The package comes with facades, helpers, and blade directives.

#### FormMaker Facades
```php
FormMaker::fromTable($table, $columns = null, $class = 'form-control', $view = null, $reformatted = true, $populated = false, $idAndTimestamps = false)
FormMaker::fromObject($object, $columns = null, $view = null, $class = 'form-control', $populated = true, $reformatted = false, $idAndTimestamps = false)
FormMaker::fromArray($array, $columns = null, $view = null, $class = 'form-control', $populated = true, $reformatted = false, $idAndTimestamps = false)
```

#### InputMaker Facades
```php
InputMaker::label($name, $attributes = [])
InputMaker::create($name, $field, $object = null, $class = 'form-control', $reformatted = false, $populated = false)
```

#### FormMaker Blade
```php
@form_maker_table($table, $columns = null, $class = 'form-control', $view = null, $reformatted = true, $populated = false, $idAndTimestamps = false)
@form_maker_object($object, $columns = null, $view = null, $class = 'form-control', $populated = true, $reformatted = false, $idAndTimestamps = false)
@form_maker_array($array, $columns = null, $view = null, $class = 'form-control', $populated = true, $reformatted = false, $idAndTimestamps = false)
```

#### InputMaker Blade
```php
@input_maker_label($name, $attributes = [])
@input_maker_create($name, $field, $object = null, $class = 'form-control', $reformatted = false, $populated = false)
```

## License
FormMaker is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

### Bug Reporting and Feature Requests
Please add as many details as possible regarding submission of issues and feature requests

### Disclaimer
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37 changes: 37 additions & 0 deletions composer.json
@@ -0,0 +1,37 @@
{
"name": "yab/formmaker",
"description": "Magical Form building Facades, helpers and more!",
"license": "MIT",
"authors": [
{
"name": "Matt Lantz",
"email": "matt@yabhq.com"
},
{
"name": "Chris Blackwell",
"email": "chris@yabhq.com"
}
],
"require": {
"php": ">=5.5.9",
"illuminate/support": "5.*",
"doctrine/dbal": "^2.5",
"laravelcollective/html": "^5.2|^5.1"
},
"require-dev": {
"illuminate/container": "^5.2|^5.1",
"mockery/mockery": "^0.9.4",
"mikey179/vfsStream": "^1.6",
"orchestra/testbench": "^3.2"
},
"autoload": {
"psr-4": {
"Yab\\FormMaker\\": "src/"
},
"files": [
"src/Helpers/form_maker.php",
"src/Helpers/input_maker.php"
]
},
"minimum-stability": "stable"
}
40 changes: 40 additions & 0 deletions config/form-maker.php
@@ -0,0 +1,40 @@
<?php

/*
|--------------------------------------------------------------------------
| Form Maker Config
|--------------------------------------------------------------------------
*/

return [

'form' => [
'group-class' => 'form-group',
'error-class' => 'has-error',
'label-class' => 'control-label',
],

'inputTypes' => [
'number' => 'number',
'integer' => 'number',
'float' => 'number',
'decimal' => 'number',
'boolean' => 'number',
'string' => 'text',
'email' => 'text',
'varchar' => 'text',
'file' => 'file',
'image' => 'file',
'datetime' => 'date',
'date' => 'date',
'password' => 'password',
'textarea' => 'textarea',
'select' => null,
'checkbox' => null,
'checkbox-inline' => null,
'radio' => null,
'radio-inline' => null,
]

];

18 changes: 18 additions & 0 deletions phpunit.xml
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="FormMaker Tests">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
18 changes: 18 additions & 0 deletions src/Facades/FormMaker.php
@@ -0,0 +1,18 @@
<?php

namespace Yab\FormMaker\Facades;

use Illuminate\Support\Facades\Facade;

class FormMaker extends Facade
{
/**
* Create the Facade.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'FormMaker';
}
}
18 changes: 18 additions & 0 deletions src/Facades/InputMaker.php
@@ -0,0 +1,18 @@
<?php

namespace Yab\FormMaker\Facades;

use Illuminate\Support\Facades\Facade;

class InputMaker extends Facade
{
/**
* Create the Facade.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'InputMaker';
}
}
95 changes: 95 additions & 0 deletions src/FormMakerProvider.php
@@ -0,0 +1,95 @@
<?php

namespace Yab\FormMaker;

use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider;
use Yab\FormMaker\Services\FormMaker;
use Yab\FormMaker\Services\InputMaker;

class FormMakerProvider extends ServiceProvider
{
/**
* Boot method.
*
* @return void
*/
public function boot()
{
$this->publishes([
__DIR__.'/../config/form-maker.php' => base_path('config/form-maker.php'),
]);
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
/*
|--------------------------------------------------------------------------
| Providers
|--------------------------------------------------------------------------
*/

$this->app->register(\Collective\Html\HtmlServiceProvider::class);

/*
|--------------------------------------------------------------------------
| Register the Utilities
|--------------------------------------------------------------------------
*/

$this->app->singleton('FormMaker', function () {
return new FormMaker();
});

$this->app->singleton('InputMaker', function () {
return new InputMaker();
});

$loader = AliasLoader::getInstance();

$loader->alias('FormMaker', \Yab\FormMaker\Facades\FormMaker::class);
$loader->alias('InputMaker', \Yab\FormMaker\Facades\InputMaker::class);

// Thrid party
$loader->alias('Form', \Collective\Html\FormFacade::class);
$loader->alias('HTML', \Collective\Html\HtmlFacade::class);

/*
|--------------------------------------------------------------------------
| Blade Directives
|--------------------------------------------------------------------------
*/

// Form Maker
Blade::directive('form_maker_table', function ($expression) {
return "<?php echo FormMaker::fromTable$expression; ?>";
});

Blade::directive('form_maker_array', function ($expression) {
return "<?php echo FormMaker::fromArray$expression; ?>";
});

Blade::directive('form_maker_object', function ($expression) {
return "<?php echo FormMaker::fromObject$expression; ?>";
});

Blade::directive('form_maker_columns', function ($expression) {
return "<?php echo FormMaker::getTableColumns$expression; ?>";
});

// Label Maker
Blade::directive('input_maker_label', function ($expression) {
return "<?php echo InputMaker::label$expression; ?>";
});

Blade::directive('input_maker_create', function ($expression) {
return "<?php echo InputMaker::create$expression; ?>";
});
}
}

0 comments on commit 93248b0

Please sign in to comment.