Skip to content

Commit

Permalink
init:micro (#31)
Browse files Browse the repository at this point in the history
* service dir structure

* generating directories via elements config

* clean up make:service

* make providers and route files

* add welcome file, update tests, skip domain dir if disabled, change stubs

* make services config like domain

* check service existence, both kinds

* pint
  • Loading branch information
shavonn committed Jan 2, 2024
1 parent 69e0639 commit aaa126c
Show file tree
Hide file tree
Showing 87 changed files with 1,130 additions and 444 deletions.
17 changes: 17 additions & 0 deletions Test/Microservices/DataThing/resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to DataThing</title>
</head>
<body class="bg-white dark:bg-gray-900">
<div class="py-8 px-4 mx-auto max-w-screen-xl text-center lg:py-16 lg:px-12">
<div href="#" class="inline-flex justify-between items-center py-1 px-1 pr-4 mb-7 text-sm text-gray-700 bg-gray-100 rounded-full dark:bg-gray-800 dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700" role="alert">
<span class="text-sm font-medium px-4 py-1.5">Enjoy your new Laraca generated service!</span>
</div>
<h1 class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-gray-900 md:text-5xl lg:text-6xl dark:text-white">DataThing</h1>
</div>
<script src="https://cdn.tailwindcss.com"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions Test/Microservices/New_Object/resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to New_Object</title>
</head>
<body class="bg-white dark:bg-gray-900">
<div class="py-8 px-4 mx-auto max-w-screen-xl text-center lg:py-16 lg:px-12">
<div href="#" class="inline-flex justify-between items-center py-1 px-1 pr-4 mb-7 text-sm text-gray-700 bg-gray-100 rounded-full dark:bg-gray-800 dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700" role="alert">
<span class="text-sm font-medium px-4 py-1.5">Enjoy your new Laraca generated service!</span>
</div>
<h1 class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-gray-900 md:text-5xl lg:text-6xl dark:text-white">New_Object</h1>
</div>
<script src="https://cdn.tailwindcss.com"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions Test/Microservices/PackageClass/resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to PackageClass</title>
</head>
<body class="bg-white dark:bg-gray-900">
<div class="py-8 px-4 mx-auto max-w-screen-xl text-center lg:py-16 lg:px-12">
<div href="#" class="inline-flex justify-between items-center py-1 px-1 pr-4 mb-7 text-sm text-gray-700 bg-gray-100 rounded-full dark:bg-gray-800 dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700" role="alert">
<span class="text-sm font-medium px-4 py-1.5">Enjoy your new Laraca generated service!</span>
</div>
<h1 class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-gray-900 md:text-5xl lg:text-6xl dark:text-white">PackageClass</h1>
</div>
<script src="https://cdn.tailwindcss.com"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions Test/Microservices/Testy/resources/views/welcome.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome to Testy</title>
</head>
<body class="bg-white dark:bg-gray-900">
<div class="py-8 px-4 mx-auto max-w-screen-xl text-center lg:py-16 lg:px-12">
<div href="#" class="inline-flex justify-between items-center py-1 px-1 pr-4 mb-7 text-sm text-gray-700 bg-gray-100 rounded-full dark:bg-gray-800 dark:text-white hover:bg-gray-200 dark:hover:bg-gray-700" role="alert">
<span class="text-sm font-medium px-4 py-1.5">Enjoy your new Laraca generated service!</span>
</div>
<h1 class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-gray-900 md:text-5xl lg:text-6xl dark:text-white">Testy</h1>
</div>
<script src="https://cdn.tailwindcss.com"></script>
</body>
</html>
37 changes: 25 additions & 12 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,12 @@
* Laraca config
*/
return [
/*
|--------------------------------------------------------------------------
| Domains
|--------------------------------------------------------------------------
| Enables optional domain argument in make commands
*/
'domains' => [
'enabled' => true,
'parent_dir' => 'Domains', // dir name or null
],

/*
|--------------------------------------------------------------------------
| Directory structure config
|--------------------------------------------------------------------------
*/
'structure' => [
'struct' => [
/*
|--------------------------------------------------------------------------
| Cast Path
Expand Down Expand Up @@ -87,6 +76,18 @@
'parent' => 'base',
],

/*
|--------------------------------------------------------------------------
| Domains
|--------------------------------------------------------------------------
| Enables optional domain argument in make commands
*/
'domain' => [
'enabled' => true,
'path' => 'Domains', // dir name or null
'parent' => 'app',
],

/*
|--------------------------------------------------------------------------
| Enum Path
Expand Down Expand Up @@ -164,6 +165,18 @@
'parent' => 'app',
],

/*
|--------------------------------------------------------------------------
| Microservice Path
|--------------------------------------------------------------------------
| make:micro
*/
'microservice' => [
'enabled' => true,
'path' => 'Microservices',
'parent' => 'app',
],

/*
|--------------------------------------------------------------------------
| Middleware Path
Expand Down
15 changes: 8 additions & 7 deletions docs/config-domains.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ If you're interested in domain-driven design or even separating your application
```php
'domains' => [
'enabled' => true,
'parent_dir' => 'Domains', // dir name or null
'path' => 'Domains', // dir name or null
'parent' => 'app',
],
```

| Option | Description |
| ------------ | :---------------------------------------------------------------------: |
| `parent_dir` | The directory you want to use as a parent. It can be whatever you like. |
| Option | Description |
| ------ | :---------------------------------------------------------------------: |
| `path` | The directory you want to use as a parent. It can be whatever you like. |

Examples:

- `'parent_dir' => 'Domains'` => `(app/Domains/Foo)`
- `'parent_dir' => 'Service'` => `(app/Service/Foo)`
- `'parent_dir' => null` => `(app/Foo)`
- `'path' => 'Domains'` => `(app/Domains/Foo)`
- `'path' => 'Service'` => `(app/Service/Foo)`
- `'path' => null` => `(app/Foo)`

## Use with make commands

Expand Down
4 changes: 2 additions & 2 deletions docs/config-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ outline: deep

Generally, every key in the config corresponds to a fairly obvious command.

Ex: `cast` key in `structure` corresponds to `make:cast`
Ex: `cast` key in `struct` corresponds to `make:cast`

## Buildng Your Structure

Expand Down Expand Up @@ -35,7 +35,7 @@ Results: `app/Data/Models`

### Via Parent

Additional keys can be added to the `structure` to serve as parent directories.
Additional keys can be added to the `struct` to serve as parent directories.

```php
'data' => [
Expand Down
2 changes: 1 addition & 1 deletion src/Commands/DomainListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function handle()
{
$domains = [];

$domainDir = Config::get('laraca.domains.parent_dir');
$domainDir = Config::get('laraca.struct.domain.path');
$domainPath = app_path($domainDir);

if ($this->files->isDirectory($domainPath)) {
Expand Down
Loading

0 comments on commit aaa126c

Please sign in to comment.