odan / slim4-skeleton

A Slim 4 Skeleton
https://odan.github.io/slim4-skeleton/
MIT License
439 stars 80 forks source link

Add demonstration URL #94

Closed peter279k closed 2 years ago

peter279k commented 2 years ago

As title, I fork the Slim4 skeleton repository and modify some stuffs to be friendly for Heroku deployment.

And I completely deploy the skeleton in the Heroku platform: https://slim4-skeleton.herokuapp.com.

I think it should be great for developers to visit the above demonstration URL to evaluate the Slim4 skeleton application.

odan commented 2 years ago

Hi @peter279k Thank you very much.

What if we put this knowledge in the documentation so that everyone could read it and configure it that way on Heroku. That way you wouldn't have to mirror the repo for every update.

peter279k commented 2 years ago

Hi @odan, thanks for your reply. I've added the sync.yml in my forked repository. And it will run the job to update the original repository automatically every ten minutes.

I need to fork the repository because some steps are conflicted with the original repository.

For example, it needs the composer.lock file when deploying the Heroku platform. And the config/env.php file needs to be under the Git version control because it's the database setting for the Heroku ClearDB MySQL addon when demonstrating the Slim4 skeleton application.

In the original repository, I think it can add some descriptions in the README.md. And they're as follows:

Please refer the [forked repository](https://github.com/peter279k/slim4-skeleton-heroku) to know more details about the Heroku deployment.
odan commented 2 years ago

For example, it needs the composer.lock file when deploying the Heroku platform.

Yes, because this is a skeleton project. The composer.lock file could be generated in a build step.

And the config/env.php file needs to be under the Git version control because it's the database setting for the Heroku ClearDB MySQL addon when demonstrating the Slim4 skeleton application.

This definitely not the recommended way. This file must never be committed to the version control. It contains sensitive information. It's like a .env file.

peter279k commented 2 years ago

You can look at the env.php file, And we can notice that the sensitive information is not presented in the file:

<?php

// Secret credentials

return function (array $settings): array {
    $url = parse_url(getenv('CLEARDB_DATABASE_URL'));
    $settings['db']['host'] = $url['host'];
    $settings['db']['port'] = '3306';
    $settings['db']['username'] = $url['user'];
    $settings['db']['password'] = $url['pass'];

    if (defined('PHPUNIT_COMPOSER_INSTALL')) {
        // PHPUnit test database
        $settings['db']['database'] = substr($url['path'], 1);
    } else {
        // Local dev database
        $settings['db']['database'] = substr($url['path'], 1);
    }

    return $settings;
};

When enabling the ClearDB MySQL addon in the Heroku, the CLEARDB_DATABASE_URL environment variable will be added in the specific Heroku App setting.

odan commented 2 years ago

Ok, this is good 👍