Skip to content

This project is an application built with the Laravel framework, dedicated to setting up a local CDN (Content Delivery Network) system.

Notifications You must be signed in to change notification settings

gedeontimothy/cdn

Repository files navigation

Local CDN

This project is an application built with the Laravel framework, dedicated to setting up a local CDN (Content Delivery Network) system. The goal is to provide an efficient solution for distributing static files (images, scripts, stylesheets, etc.) across a local network, thereby improving loading times and the performance of applications.

Installation and Setup

Installs all the project dependencies defined in the composer.json file.

composer install

Copies the example file .env.example to .env for application configurations.

cp .env.example .env    # for Linux and MacOS
copy .env.example .env  # for Windows

Generates an application key and adds it to the .env file.

php artisan key:generate

Executes the database migrations, creating the necessary tables.

php artisan migrate

Starts a local development server at the address http://127.0.1.1.

Note:

You can configure the host in the server-*-server.(bat|sh) files located in the app/bin/ directory.
You can also start the server by running these server startup files without the console command.
If you are on MacOS, your server startup file is server-linux-server.sh.

composer serve
Local Domain

You can generate the local domain name by running (as administrator mode) the following command:

php artisan app:local-domain

This command will configure the local domain names cdn.net and www.cdn.net for the IP address 127.0.1.1.

However, you can still modify the domain names to be generated for your chosen IP address. Just display the help for the command by running:

php artisan app:local-domain -h

The domain name is stored in the file :

  • Sur Windows : C:\Windows\System32\drivers\etc\hosts
  • Sur Linux et MacOS : /etc/hosts

Initialize data in the CDN database

Start by configuring the folders where your files are located. In the app configuration file, add the file_init key:

Or you can also configure your folders directly in the method App\Console\Commands\InitLocalFile::getFolders

    // ...
    'file_init' => [
        [
            // folder is required: string|array
            'folder' => '/absolute_folder_path', // Or ['/absolute_folder_path_1', '/absolute_folder_path_2']

            // categories are optional: array - default: []
            'categories' => ['category1', 'categoryX'],

            // only-extension is optional: array - default: []
            'only-extension' => ['jpeg' /*, 'mp4', 'c', */],

            // recursive-folder is optional: bool - default: false
            'recursive-folder' => true,

            // type is optional: string|callable - default: function autoTypeDetect(): string|null
                // The autoTypeDetect function returns 'document', 'font', 'audio', 'image', 'video', 'text' or NULL as file types
            'type' => 'file-type',
        ],
        // ...
    ]

Then run the following command to create the database data linked to the files in your folders

php artisan init-local-file


Laravel Logo

Build Status Total Downloads Latest Stable Version License

About Laravel

Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as:

Laravel is accessible, powerful, and provides tools required for large, robust applications.

Learning Laravel

Laravel has the most extensive and thorough documentation and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.

You may also try the Laravel Bootcamp, where you will be guided through building a modern Laravel application from scratch.

If you don't feel like reading, Laracasts can help. Laracasts contains thousands of video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.

Laravel Sponsors

We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel Partners program.

Premium Partners

Contributing

Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the Laravel documentation.

Code of Conduct

In order to ensure that the Laravel community is welcoming to all, please review and abide by the Code of Conduct.

Security Vulnerabilities

If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via taylor@laravel.com. All security vulnerabilities will be promptly addressed.

License

The Laravel framework is open-sourced software licensed under the MIT license.