Skip to content

Commit ec41120

Browse files
committed
First Release
0 parents  commit ec41120

File tree

5 files changed

+197
-0
lines changed

5 files changed

+197
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/vendor
2+
.DS_STORE
3+
.idea

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 CodingwithRK
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<h1 align="center">RK Project Setup</h1>
2+
3+
<p align="center">
4+
<a>
5+
<img alt="Packagist License" src="https://img.shields.io/packagist/l/codingwithrk/rk-project-setup">
6+
</a>
7+
<a>
8+
<img alt="Packagist Version" src="https://img.shields.io/packagist/v/codingwithrk/rk-project-setup">
9+
</a>
10+
</p>
11+
12+
Basically everytime I started new [Laravel](https://laravel.com/) project I have set up lot of things like
13+
14+
- [NPM](https://www.npmjs.com/)
15+
- [Livewire](https://livewire.laravel.com/)
16+
- [FluxUI](https://fluxui.dev/)
17+
18+
For FluxUI I have to change file like
19+
20+
- app.blade.php
21+
- app.css
22+
23+
So, I decided to create this package. If you are also same like me then you can use this package in your next **Laravel** project.
24+
25+
## How to use
26+
27+
### In your laravel project
28+
29+
```bash
30+
composer require codingwithrk/rk-project-setup
31+
```
32+
33+
> This is ask for composer confirmation then give yes (y).
34+
>
35+
> That's it you it will take care rest of the installations.
36+
37+
## Credits
38+
39+
- [CodingwithRK](https://codingwithrk.com/)
40+
41+
## License
42+
43+
This is open-sourced software licensed under the [MIT license](/LICENSE).

composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "codingwithrk/rk-project-setup",
3+
"description": "Auto-setup a new Laravel project with Livewire + Flux",
4+
"type": "composer-plugin",
5+
"license": "MIT",
6+
"require": {
7+
"composer-plugin-api": "^2.0"
8+
},
9+
"autoload": {
10+
"psr-4": {
11+
"Codingwithrk\\RkProjectSetup\\": "src/"
12+
}
13+
},
14+
"extra": {
15+
"class": "Codingwithrk\\RkProjectSetup\\ProjectSetupInstaller"
16+
}
17+
}

src/ProjectSetupInstaller.php

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
3+
namespace Codingwithrk\RkProjectSetup;
4+
5+
use Composer\Composer;
6+
use Composer\IO\IOInterface;
7+
use Composer\Plugin\PluginInterface;
8+
use Composer\EventDispatcher\EventSubscriberInterface;
9+
use Composer\Installer\PackageEvent;
10+
use Composer\Installer\PackageEvents;
11+
12+
class ProjectSetupInstaller implements PluginInterface, EventSubscriberInterface
13+
{
14+
public function activate(Composer $composer, IOInterface $io)
15+
{
16+
}
17+
18+
public function deactivate(Composer $composer, IOInterface $io)
19+
{
20+
}
21+
22+
public function uninstall(Composer $composer, IOInterface $io)
23+
{
24+
}
25+
26+
public static function getSubscribedEvents(): array
27+
{
28+
return [
29+
PackageEvents::POST_PACKAGE_INSTALL => 'handlePostInstall',
30+
];
31+
}
32+
33+
public function handlePostInstall(PackageEvent $event)
34+
{
35+
$io = $event->getIO();
36+
37+
// Run npm install
38+
$io->write("<info>📦 Running npm install...</info>");
39+
shell_exec("npm install");
40+
$io->write("<comment>✅ npm install completed!</comment>");
41+
42+
// Install Livewire
43+
$io->write("<info>📦 Installing Livewire...</info>");
44+
shell_exec("composer require livewire/livewire");
45+
$io->write("<comment>✅ Livewire installed!</comment>");
46+
47+
// Publish Livewire config
48+
$io->write("<info>⚙️ Publishing Livewire config...</info>");
49+
shell_exec("php artisan livewire:publish --config");
50+
$io->write("<comment>✅ Livewire config published!</comment>");
51+
52+
// Generate Livewire layout
53+
$io->write("<info>🧱 Generating Livewire layout...</info>");
54+
shell_exec("php artisan livewire:layout");
55+
$io->write("<comment>✅ Layout generated!</comment>");
56+
57+
// Install Flux
58+
$io->write("<info>📦 Installing Flux...</info>");
59+
shell_exec("composer require livewire/flux");
60+
$io->write("<comment>✅ Flux installed!</comment>");
61+
62+
// Modify layout file
63+
$layout = 'resources/views/components/layouts/app.blade.php';
64+
if (file_exists($layout)) {
65+
$io->write("<info>✏️ Updating layout file...</info>");
66+
file_put_contents($layout, <<<BLADE
67+
<!DOCTYPE html>
68+
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
69+
<head>
70+
<meta charset="utf-8">
71+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
72+
73+
<title>{{ \$title ?? 'Page Title' }}</title>
74+
@vite(['resources/css/app.css', 'resources/js/app.js'])
75+
@fluxAppearance
76+
</head>
77+
<body>
78+
{{ \$slot }}
79+
@fluxScripts
80+
</body>
81+
</html>
82+
BLADE
83+
);
84+
$io->write("<comment>✅ Layout updated!</comment>");
85+
}
86+
87+
// Modify app.css
88+
$css = 'resources/css/app.css';
89+
if (file_exists($css)) {
90+
$io->write("<info>🎨 Updating app.css file...</info>");
91+
file_put_contents($css, <<<CSS
92+
@import 'tailwindcss';
93+
@import '../../vendor/livewire/flux/dist/flux.css';
94+
95+
@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
96+
@source '../../storage/framework/views/*.php';
97+
@source '../**/*.blade.php';
98+
@source '../**/*.js';
99+
100+
@custom-variant dark (&:where(.dark, .dark *));
101+
@theme {
102+
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
103+
'Segoe UI Symbol', 'Noto Color Emoji';
104+
}
105+
CSS
106+
);
107+
$io->write("<comment>✅ app.css updated!</comment>");
108+
}
109+
110+
$io->write("<info>🎉 rk-project-setup completed successfully!</info>");
111+
}
112+
113+
}

0 commit comments

Comments
 (0)