PHPackages                             vizrex/laraviz - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vizrex/laraviz

ActiveLaravel-package[Utility &amp; Helpers](/categories/utility)

vizrex/laraviz
==============

A base package with various helpers and abstract classes, acting as a foundation and a standard for other packages.

1.0.2(7y ago)163444proprietaryPHPPHP &gt;=7.0.0

Since Jan 16Pushed 7y ago2 watchersCompare

[ Source](https://github.com/Vizrex/laraviz)[ Packagist](https://packagist.org/packages/vizrex/laraviz)[ RSS](/packages/vizrex-laraviz/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (3)Used By (4)

> # READ THIS FIRST
>
> [](#read-this-first)
>
> It is highly recommended for all contributors to update this file whenever there's a major update in source code. Use [this tool](https://stackedit.io/app#) for easy editing or [visit this page](https://help.github.com/articles/basic-writing-and-formatting-syntax/) for comprehensive guide on markdown syntax.

Introduction
============

[](#introduction)

This is base package with various helpers and abstract classes, acting as a foundation and a standard for other packages. It is highly recommended to build future packages and projects on top of this package.

Included Items
==============

[](#included-items)

Base Classes
------------

[](#base-classes)

### BaseCommand

[](#basecommand)

A base class for Console commands of Laravel. It contains three new methods:

- `debug()`This method calls `info()` of base class and outputs the given string in `VERY_VERBOSE` mode i.e. the given string will be displayed on console only when `-vvvv` flag will be passed to a command.
- `setNamespace()`This is an abstract method. It should set `$this->namespace` property of command. Ideally its value should be taken from static `getNamespace()` method of Service Provider class as implemented in `BaseServiceProvider` and its child classes.
- `setDefaultTranslationFile()`This method sets the `$defaultTranslationFile` property of command. It is the name of file from which the localized strings should be loaded by default.
- `str()`This is a helper method that calls `__()` or `trans()` method to load localized strings based upon the values of `$namespace` and `$defaultTranslationFile` property of command. However, it is overloaded to accept a translations file name other than `$defaultTranslationFile`.

### BaseException

[](#baseexception)

### BaseController

[](#basecontroller)

### BaseServiceProvider

[](#baseserviceprovider)

It has a static method `getNamespace()` that returns the namespace of this service provider in a specific format.

### BaseRepository

[](#baserepository)

It has the implementation of basic methods related to a resource:

- `index()`
- `find()`
- `store()`
- `update`
- `destroy()`

### BaseMigration

[](#basemigration)

This class can be extended by Laravel migration classes. Child class would need to implement following three methods:

- `__construct()`It should call `parent::__construct("my_table")` where `my_table` should be replaced with appropriate table name. It is highly recommended to get this string by calling `getTableName()` of a model for which this migration is intended.
- `doChanges()`This method will get an object of `Blueprint`. Developer can write the schema related statements straightforwardly without worrying about existence and non-existence of table. Use it as substitute of traditional `up()` method. However `up()` method can also be overridden if required.
- `undoChanges()`This function gets the table name as parameter. Use it as substitute of traditional `down()` method. However the later can still be overridden when required.

### BaseSeeder

[](#baseseeder)

### BaseTrait: LaravizModel

[](#basetrait-laravizmodel)

Use this trait in Eloquent Models and override `findByIdentifier()` method. There can be more than one identifiers of a model e.g. a user can be identified by its `id` as well as by `email` attribute. So instead of writing `orWhere` clauses, `findByIdentifier()` method can be called neatly.

### Base Resource

[](#base-resource)

This class has following two additional methods as compared to default `Resource` of Laravel:

- `toCompactArray`
- `toFullArray`

There're two properties of this class:

#### Static: `$defaultResponseType`

[](#static-defaultresponsetype)

Default response type can be set with this property (default is `ResponseType::FULL`)

#### Non-static: `$responseType`

[](#non-static-responsetype)

This property overrides the `$defaultResponseType` and can be set only via constructor.

Default Routes
==============

[](#default-routes)

Following open routes will be added to the application using this package:

### `/time`

[](#time)

It returns current datetime with timezone details as JSON string.

### `/info`

[](#info)

It returns the output of `phpinfo()`

These routes can be customized using config/laraviz.php file. Execute the following command to publish this config file:

```
php artisan vendor:publish --tag=Vizrex_Laraviz
```

Added Helpers
=============

[](#added-helpers)

Eloquent Helpers
----------------

[](#eloquent-helpers)

### `get_fillables()`

[](#get_fillables)

It returns the fillable attributes as an associative array having `key` and `value`.

Html Helpers
------------

[](#html-helpers)

### `public_url()`

[](#public_url)

Returns base URL of application.

### `css($absolutePathOrArray)`

[](#cssabsolutepathorarray)

Adds the HTML tag for including CSS. You can pass either an string, an array or an associative array where the key should contain the URL of CSS and the value should contain an expression such that CSS would be included only when the expression yields to true.

```
css("http://sample-cdn.com/example.css");
css(["http://abc.com/first.css", "http://abc.com/second.css"]);
css(["http://abc.com/first.css", ["http://abc.com/second.css" => 1 > 2], "http://www.example.com/main.css"]);
```

### `public_css($relativePath)`

[](#public_cssrelativepath)

Adds the HTML tag for including css relative to `public/css` folder.

### `js($absolutePathOrArray)`

[](#jsabsolutepathorarray)

Adds the HTML tag for including Javascript file. See the description of `css()` method. This method works exactly like that.

### `public_js($relativePath)`

[](#public_jsrelativepath)

Adds the HTML tag for including js relative to `public/js`

Path Helpers
------------

[](#path-helpers)

### `merge_url()`

[](#merge_url)

Currently it simply concatenates two string and adds a forward slash `/` between them. It can be enhanced to handle more complex situations.

String Helpers
--------------

[](#string-helpers)

### `str_concat()`

[](#str_concat)

This function accepts variable number of parameters and concatenates.

### `s()`

[](#s)

This helper method is a wrapper on `trans()` and `__()` methods of Laravel. Using this method will eliminate the need of specifying language/translations file name every time. Simply specify a default language file in `config/laraviz.php` file and only pass the `key` to `s()` method. It will simply concatenate the configured file name to the given key and pass it to `trans()` method.

System Helpers
--------------

[](#system-helpers)

Following methods have very basic implementation. They're sort of thin wrappers. However there's a lot of room for enhancements

- `v_echo()`
- `v_info()`
- `v_debug`
- `v_error()`

To-dos
======

[](#to-dos)

Following are the approved items:

- Improve `merge_url()` to handle complex situations e.g. concatenate relative urls to create an absolute one.
- Improve `SystemHelpers`. Ideally there should be a separate package for logging and `SystemHelpers` should only be thin wrappers on top of our custom logger.

Wishlist
========

[](#wishlist)

Add the suggestions in this wishlist. Only approved wishlist items can be moved to To-dos list:

- Item-1

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2671d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/49ed679f8af1a3a1da9a187d1ce6520287263a4d1c575617708fc76cbcff3ba4?d=identicon)[vizrex](/maintainers/vizrex)

---

Top Contributors

[![zeshanfarooqi](https://avatars.githubusercontent.com/u/1576772?v=4)](https://github.com/zeshanfarooqi "zeshanfarooqi (14 commits)")[![nafeeshasan](https://avatars.githubusercontent.com/u/42134152?v=4)](https://github.com/nafeeshasan "nafeeshasan (2 commits)")

### Embed Badge

![Health badge](/badges/vizrex-laraviz/health.svg)

```
[![Health](https://phpackages.com/badges/vizrex-laraviz/health.svg)](https://phpackages.com/packages/vizrex-laraviz)
```

###  Alternatives

[simplesquid/nova-enum-field

A Laravel Nova field to add enums to resources.

52391.9k2](/packages/simplesquid-nova-enum-field)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
