Skip to content

Commit ff98f0d

Browse files
Merge pull request #12 from HichemTab-tech/handle-paths-errors
Add troubleshooting guide and improve error handling in LaravelFS
2 parents a624ba6 + c244d2a commit ff98f0d

File tree

4 files changed

+46
-5
lines changed

4 files changed

+46
-5
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,34 @@ A starter kit must meet the following requirements:
131131

132132
---
133133

134+
## **🐧 Ubuntu Users: Fixing LaravelFS Command Not Found Issue**
135+
136+
If you installed LaravelFS but **can’t run the `laravelfs` command**,
137+
it might be because Composer's global bin folder is **not in your system's PATH**.
138+
139+
### **🔧 Solution: Add Composer Bin to PATH**
140+
1️⃣ Open your terminal and edit the `~/.bashrc` file:
141+
```sh
142+
nano ~/.bashrc
143+
```
144+
_(If needed, use `sudo nano ~/.bashrc`)_
145+
146+
2️⃣ Add this line at the **bottom** of the file:
147+
```sh
148+
export PATH="$PATH:$HOME/.config/composer/vendor/bin"
149+
```
150+
151+
3️⃣ Save the file (`CTRL + X`, then `Y`, then `Enter`).
152+
153+
4️⃣ Apply the changes:
154+
```sh
155+
source ~/.bashrc
156+
```
157+
158+
✅ Now, try running `laravelfs` again—it should work! 🚀
159+
160+
---
161+
134162
## **Contributing**
135163
Thank you for considering contributing to LaravelFS! We welcome contributions to improve the installer and keep it updated. Please submit issues and pull requests to the [GitHub repository](https://github.com/HichemTab-tech/LaravelFS).
136164

bin/laravelfs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if (file_exists(__DIR__.'/../../../autoload.php')) {
99
}
1010

1111
// Define our own version and the Laravel Installer version we aim to match.
12-
$laravelFSVersion = '1.2.0';
12+
$laravelFSVersion = '1.2.1';
1313
$laravelInstallerVersion = '5.13.0';
1414

1515
// Compose the displayed version string.

src/NewCommand.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
351351
}
352352

353353
// Save the template globally
354-
$this->saveTemplateCommand($templateName, $templateDescription, $templateCommand);
354+
if (!$this->saveTemplateCommand($templateName, $templateDescription, $templateCommand)) {
355+
error('Failed to save the template.');
356+
return Command::FAILURE;
357+
}
355358

356359
$output->writeln(" <bg=blue;fg=white> INFO </> Template <options=bold>[$templateName]</> created successfully.");
357360
$output->writeln(" <fg=gray>➜</> You can now use this template by running <options=bold>laravelfs use $templateName</>");
@@ -1202,7 +1205,7 @@ private function createTemplateCommand(InputInterface $input): string
12021205
return implode(' ', $commandParts);
12031206
}
12041207

1205-
protected function saveTemplateCommand(mixed $templateName, mixed $templateDescription, string $templateCommand): void
1208+
protected function saveTemplateCommand(mixed $templateName, mixed $templateDescription, string $templateCommand): bool
12061209
{
12071210
// Get the global config path for storing templates
12081211
$configPath = $this->getGlobalTemplatesPath();
@@ -1234,6 +1237,15 @@ protected function saveTemplateCommand(mixed $templateName, mixed $templateDescr
12341237
'description' => $templateDescription??"",
12351238
'command' => $templateCommand,
12361239
];
1237-
file_put_contents($configPath, json_encode($templatesConfig, JSON_PRETTY_PRINT));
1240+
$done = file_put_contents($configPath, json_encode($templatesConfig, JSON_PRETTY_PRINT)) !== false;
1241+
if (!$done) {
1242+
if (windows_os()) {
1243+
error('Failed to save the template. Please check the permissions of the directory.');
1244+
} else {
1245+
error('Failed to save the template. Please check the permissions of the file or use sudo.');
1246+
}
1247+
}
1248+
1249+
return $done;
12381250
}
12391251
}

tests/Unit/NewTemplateCommandTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
// Create a dummy NewTemplateCommand that overrides saveTemplateCommand() to capture the saved template.
1010
$this->command = new class extends NewTemplateCommand {
1111
public array|null $savedTemplate = null;
12-
public function saveTemplateCommand($templateName, $templateDescription, $templateCommand): void {
12+
public function saveTemplateCommand($templateName, $templateDescription, $templateCommand): bool {
1313
$this->savedTemplate = [
1414
'name' => $templateName,
1515
'description' => $templateDescription,
1616
'command' => $templateCommand,
1717
];
18+
return true;
1819
}
1920
};
2021

0 commit comments

Comments
 (0)