Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mawuva/laravel-custom-view-components
A bunch of commons view components you usually use in your laravel project
https://github.com/mawuva/laravel-custom-view-components
laravel laravel-package view viewcomponent
Last synced: 7 days ago
JSON representation
A bunch of commons view components you usually use in your laravel project
- Host: GitHub
- URL: https://github.com/mawuva/laravel-custom-view-components
- Owner: mawuva
- License: mit
- Created: 2021-09-04T14:08:36.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-09T03:14:56.000Z (almost 3 years ago)
- Last Synced: 2024-07-23T18:59:48.449Z (4 months ago)
- Topics: laravel, laravel-package, view, viewcomponent
- Language: PHP
- Homepage: https://packagist.org/packages/mawuekom/laravel-custom-view-components
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# A bunch of Custom View Components
This package provide commons view components you usually use in your laravel project.
## Installation
You can install the package via composer:
```bash
composer require mawuekom/laravel-custom-view-components
```## Usage
Once install, go to `config/app.php` to add `CustomponentsServiceProvider` in providers array
Laravel 5.5 and up Uses package auto discovery feature, no need to edit the `config/app.php` file.
- #### Service Provider
```php
'providers' => [...
Mawuekom\Customponents\CustomponentsServiceProvider::class,
],
```- #### Publish Assets
```bash
php artisan vendor:publish --provider="Mawuekom\Customponents\CustomponentsServiceProvider"
```Or you can publish config
```bash
php artisan vendor:publish --provider="Mawuekom\Customponents\CustomponentsServiceProvider" --tag="config"
```#### Configuration
* There are many configurable options which have been extended to be able to configured via `.env` file variables.
* See config file: [customponents.php](https://github.com/mawuva/laravel-custom-view-components/blob/main/config/customponents.php).```php
env('APP_NAME', 'My Laravel Project'),/*
|--------------------------------------------------------------------------
| Bunch of features to enable or disable.
|--------------------------------------------------------------------------
*/'enable' => [
'app_style_sheet' => true,
'app_script' => true,
],
];
```Once all this is done, you can go in your `welcome.blade.php` and add the code below...
```php
My Laravel Website
Some content here
```
* The `section` parameter is here to help you when you want to define different views or section for a guest or logged user.
#### If you want you add some assets like style sheets and scripts links in your webpage, don't be worry.
**It's very simple.**This package is provided with a view component helper called `Section` which can help you include section of your project in another section.
Take a look at [headers.blade.php](https://github.com/mawuva/laravel-custom-view-components/blob/main/resources/views/components/partials/headers.blade.php) component source code.
```php
@yield('styles')
```You will see a classic blade directive : `@yield('styles')`
You can then use this like that...
```php
your content goes here
```
So to include assets links in your webpage, just do it like that
```php
My Laravel Website
Some content here
```
It is nice, isn't it !!! 🙂😉
* On top of that, you also a components [assets.blade.php](https://github.com/mawuva/laravel-custom-view-components/blob/main/resources/views/components/resources/assets.blade.php) which you can use to add assets links in your page just like that :
```php
```
Then, your page could look like that...
```php
My Laravel Website
Some content here
```
#### Layout
There is a [master.blade.php](https://github.com/mawuva/laravel-custom-view-components/blob/main/resources/views/components/layouts/master.blade.php) layout that can simplify your `welcome.blade.php` :
```php
// Your style sheet goes here.
My Laravel Website
Some content here
// Your script files goes here.
```
### Enjoy 🙂😉👌🔥
### Testing
```bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.