PHPackages                             digbang/laravel-project - 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. digbang/laravel-project

ActiveProject

digbang/laravel-project
=======================

project-name

v9.3.0(3y ago)11492proprietaryPHPPHP ^8.0.2

Since Jan 30Pushed 3y ago2 watchersCompare

[ Source](https://github.com/digbang/laravel-project)[ Packagist](https://packagist.org/packages/digbang/laravel-project)[ RSS](/packages/digbang-laravel-project/feed)WikiDiscussions master-digbangs-way Synced 1mo ago

READMEChangelog (10)Dependencies (34)Versions (65)Used By (0)

project-name
============

[](#project-name)

Installation
------------

[](#installation)

1. Clone repository
2. Start the containers
3. Access the PHP container and:

> A. **RUN** `composer config -g github-oauth.github.com `(To create the token go to:  and set the **repo** permissions)

> B. **RUN** `composer install`

> C. **RUN** `ln -s /proxies proxies`

> D. **RUN** `composer build`

Minio configuration
-------------------

[](#minio-configuration)

1. ADD "127.0.0.1 s3" to your hosts file
2. ACCESS `http://localhost:9000/minio`,
3. Login with the access and secret keys located in `docker-compose.yml`.
4. Create a bucket with some name. Add a R/W policy to the bucket.
5. Configure the bucket name in your env file
6. Change the filesystem driver to `minio`

Sentry configuration
--------------------

[](#sentry-configuration)

2. Configure your .env variables
3. Enable Sentry on your .env file

System Configuration
--------------------

[](#system-configuration)

- Remember that all sites must use HTTPS. And please choose a proper redirect:
    -  should redirect to
    -  should redirect to
    -  should redirect to
    - The sub-domain (www), can be interchanged in the examples. But you must choose to use it and redirect TO it or not use it and redirect FROM it.
    - Please see docker/apache/default.conf for the server configuration to access the site and resources.

Publish Assets
--------------

[](#publish-assets)

1. `php artisan vendor:publish --provider "Digbang\\Backoffice\\BackofficeServiceProvider" --tag assets --force`

Compiling Assets (Vite)
-----------------------

[](#compiling-assets-vite)

Vite is a modern frontend build tool that provides an extremely fast development environment and bundles your code for production.

In order to serve the assets for development you should use the `npm run dev` command (that compile the assets and server then through localhost:3000), and for production builds you should use the `npm run build` command.

If you use Vite, make sure that your layout uses the @vite directive and points to the resources correctly: @vite(\['resources/css/app.css', 'resources/js/app.js'\])

For more information about Vite, please follow the official documentation:

Patrol - Track vulnerable or outdated dependencies
--------------------------------------------------

[](#patrol---track-vulnerable-or-outdated-dependencies)

Patrol is an elegant command-line tool that keeps your PHP Project's dependencies in check.

1. `composer patrol`

Pint - Code Style fixer
-----------------------

[](#pint---code-style-fixer)

Laravel Pint is an opinionated PHP code style fixer for minimalists. Pint is built on top of PHP-CS-Fixer and makes it simple to ensure that your code style stays clean and consistent.

1. `composer cs`

SPECIAL DIRECTORIES
-------------------

[](#special-directories)

Permissions

```
// at the root of the project (only on linux)
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

```

Proxies (ensure the symlink exists...)

```
// ... if not; inside of the PHP container run
ln -s /proxies /proxies

```

Repositories on Request
-----------------------

[](#repositories-on-request)

If you need a repository you may do this:

Example:

```
public function users(): ?array
{
    if ($this->input(self::USER_IDS)) {
        return $this->repository(UserRepository::class)->find($this->input(self::USER_IDS));
    }

    return null;
}
```

If you need a repository method that doesnt exist in ReadRepository, you must create a private method into your request.

Example:

```
private function roleRepository(): RoleRepository
{
    /** @var RoleRepository $repository */
    $repository = $this->repository(RoleRepository::class);

    return $repository;
}

public function roles(): ?array
{
    if ($this->input(self::ROLE_NAME)) {
        return $this->roleRepository()->findByName($this->input(self::ROLE_NAME));
    }

    return null;
}
```

HTTP Codes references
---------------------

[](#http-codes-references)

The next list contains the HTTP codes returned by the API and the meaning in the present context:

- HTTP 200 Ok: the request has been processed successfully.
- HTTP 201 Created: the resource has been created. It's associated with a POST Request.
- HTTP 204 No Content: the request has been processed successfully but does not need to return an entity-body.
- HTTP 400 Bad Request: the request could not been processed by the API. You should review the data sent to.
- HTTP 401 Unauthorized: When the request was performed to the login endpoint, means that credentials are not matching with any. When the request was performed to another endpoint means that the token it's not valid anymore due TTL expiration.
- HTTP 403 Forbidden: the credentials provided with the request has not the necessary permission to be processed.
- HTTP 404 Not Found: the endpoint requested does not exist in the API.
- HTTP 422: the payload sent to the API did not pass the validation process.
- HTTP 500: an unknown error was triggered during the process.

Please refer to  for reference

Php Stan
--------

[](#php-stan)

You should now have a `phpstan.neon` file that allows you to configure the basics of this package.

Php Insight
-----------

[](#php-insight)

### Config File

[](#config-file)

You should now have a `config/insights.php` file that allows you to configure the basics of this package.

Laravel Responder
-----------------

[](#laravel-responder)

### Creating Responses

[](#creating-responses)

```
return responder()
    ->success($user, UserProfileTransformer::class)
    ->meta([
        'meta' => $this->shouldRefreshToken(),
    ])
    ->respond();
```

### Creating Transformers

[](#creating-transformers)

`php artisan make:transformer ProductTransformer --plain`

### Handling Exceptions

[](#handling-exceptions)

#### Convert Custom Exceptions

[](#convert-custom-exceptions)

In addition to letting the package convert Laravel exceptions, you can also convert your own exceptions using the `convert` method in the `render` method:

```
$this->convert($exception, [
    InvalidValueException => PageNotFoundException,
]);
```

You can optionally give it a closure that throws the new exception, if you want to give it constructor parameters:

```
$this->convert($exception, [
    MaintenanceModeException => function ($exception) {
        throw new ServerDownException($exception->retryAfter);
    },
]);
```

### Creating HTTP Exceptions

[](#creating-http-exceptions)

An exception class is a convenient place to store information about an error. The package provides an abstract exception class `Flugg\Responder\Exceptions\Http\HttpException`, which has knowledge about status code, an error code and an error message. Continuing on our product example from above, we could create our own `HttpException` class:

```
