GithubHelp home page GithubHelp logo

jeffersonsimaogoncalves / laravel-preview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gregoriohc/laravel-preview

1.0 1.0 0.0 23 KB

Views preview package for Laravel

License: MIT License

Shell 2.16% PHP 97.28% HTML 0.56%

laravel-preview's Introduction

Preview

Latest Version on Packagist Software License Build Status StyleCI Quality Score Code Climate Test Coverage Total Downloads

WARNING: USE THIS PACKAGE ONLY IN LOCAL/DEBUG MODE! ENABLING THIS PACKAGE IN PRODUCTION ENVIRONMENTS CAN REPRESENT A BIG SECURITY ISSUE!

View preview package for Laravel

This package can be used to preview your laravel views without needing to create a route or controller to load the view. It can also be useful if you want to preview your emails views without needing to send them.

Contents

Installation

You can install the package via composer:

composer require gregoriohc/laravel-preview

You must install the service provider:

// config/app.php
'providers' => [
    ...
    Gregoriohc\Preview\PreviewServiceProvider::class,
],

Usage

Now, if you are in local environment with debug mode enabled, you can access the preview route.

The preview route path has the following structure: /_preview/{view}?{params}

The {view} can be any app or package view, using the dot and namespace notation of Laravel (ex.: welcome, errors.503, mypackage::myview)

For example, if you want to preview the Laravel default welcome page, you can go to: /_preview/welcome

The optional {params} can be a list of parameters that will be converted to variables and passed to the view. The key of the parameter will be the variable name, and the value will be transformed depending on its format. The possible formats are the following:

  • Object from json: If you pass a json string, it will be automatically converted to an object. For example: user={"name": "John Doe", "email": "[email protected]"}
  • Model object: To load a model object, just pass (separated by ::) the model class (with full namespace) and the object ID you are looking for. For example: user=App\User::1.
  • Class method call: To call a class method, just pass (separated by ::) the class (with full namespace), the method, and a list of params. For example: appname=Config::get::app.name or something=MyClass::myMethod::param_1::param_2::param_3. If the method is static, it will called statically, if not, a class object will be instantiated and the method will be called.
  • On any other case, the value will be passed without changes

More examples:

  • /_preview/emails.user.welcome?user=App\User::1
  • /_preview/admin.user.show?user=App\User::1
  • /_preview/mypackage::my.fantastic.view?something=Cache::get::something&anotherthing=textcontent&somenumber=123

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

laravel-preview's People

Contributors

gregoriohc avatar

Stargazers

 avatar

Watchers

 avatar

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.