-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
limoncello app on subfolders usage #35
Comments
As far as I understand you have a single database for your users. If so why not having a single domain for API as well? |
got it. yea. sounds like it was redundant.
they are entirely two (limoncello-php/app) |
They both can work with the same database. Both apps can share some tables (e.g. users) and have their own ones. Auth tokens could be issued by any of them or both. As they share users and tokens a token will work for both apps. |
how to set up? |
noted. let me try it out and namespace the table to differentiate. |
this approach was good. but as more applications created. more different namespaced table will be store on same database. will it be a confusion and lack of isolation? |
You're asking about a very generic topic of software solutions design. My response was a sample high-level design for your requirement of having monolith solution. |
ya. agree :p |
could i define two group of database setting in limoncello-app? |
I think the easiest way would be adding custom config(s) and create database |
i see, so would have to add custom setting via class Doctrine and .env |
though having subfolder usage on limoncello app was not a good practice. but i observed there was a trailing "/" slash problem:
is there any workaround on it? |
adding a trailing slash is a quite common question. Here are a couple of first googled links |
having tried to create custom config and create database connection,
all these steps works found. but i found the return connection object still capturing the .env config settings. |
reproduce the issue as follow:
|
sorry, i found i shall change those 'DB_' suffixed environment variable to another one like 'DB_OAUTH_'... etc.. |
I see you're trying to emulate built-in class. Custom classes do not need to support all doctrine connection possibilities and are not needed to be extensible as standard settings. So it can be significantly simplified.
<?php namespace App\Container;
use Doctrine\DBAL\Connection;
/**
* @package App
*/
class AnotherDoctrineConnection extends Connection
{
}
<?php namespace Settings;
use Dotenv\Dotenv;
use Limoncello\Contracts\Settings\SettingsInterface;
/**
* @package Settings
*/
class AnotherDoctrine implements SettingsInterface
{
const KEY_FILE_PATH = 0;
/**
* @inheritdoc
*/
public function get(array $appConfig): array
{
(new Dotenv(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', '..'])))->load();
$dbFile = getenv('DB_FILE');
$dbPath = realpath(implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'storage', $dbFile]));
return [
self::KEY_FILE_PATH => $dbPath,
];
}
}
<?php namespace App\Container;
use Doctrine\DBAL\DriverManager;
use Limoncello\Contracts\Application\ContainerConfiguratorInterface;
use Limoncello\Contracts\Container\ContainerInterface;
use Limoncello\Contracts\Settings\SettingsProviderInterface;
use Psr\Container\ContainerInterface as PsrContainerInterface;
use Settings\AnotherDoctrine;
/**
* @package App
*/
class AnotherDoctrineConfigurator implements ContainerConfiguratorInterface
{
/**
* @inheritdoc
*/
public static function configureContainer(ContainerInterface $container): void
{
$container[AnotherDoctrineConnection::class] = function (PsrContainerInterface $container) {
list(AnotherDoctrine::KEY_FILE_PATH => $filePath) =
$container->get(SettingsProviderInterface::class)->get(AnotherDoctrine::class);
$connection = DriverManager::getConnection([
'driver' => 'pdo_sqlite',
'user' => '',
'password' => '',
'path' => $filePath,
'charset' => 'UTF8',
]);
return $connection;
};
}
}
$connection = $container->get(AnotherDoctrineConnection::class); |
You're free to use any prefixes you like 😉 And btw do you really need to put second file path into env variable? Can it be just set in settings? |
i am going to put multiple apps on a single subdomains, i.e api.domain.com;
where each subfolder house corresponding limoncello app like:
api.domain.com/school1/subschool1/...
where api endpoint api.domain.com/school1/subschool1/v1/users... etc...
i did some adjustment on nginx like
is it a right approach to bring up limoncello app on subfolder usage ?
The text was updated successfully, but these errors were encountered: