1. Go to this page and download the library: Download fullsmack/laravel-slice library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fullsmack / laravel-slice example snippets
'providers' => [
// ... other providers
\Slice\Pizza\PizzaServiceProvider::class,
\Slice\Order\OrderServiceProvider::class,
],
use FullSmack\LaravelSlice\Slice;
use FullSmack\LaravelSlice\SliceServiceProvider;
final class PizzaServiceProvider extends SliceServiceProvider
{
public function configure(Slice $slice): void
{
$slice->setName('pizza');
}
}
public function configure(Slice $slice): void
{
$slice->setName('order')
->useRoutes() // Load routes from routes/
->useViews() // Load views from resources/views
->useTranslations() // Load translations from lang/
->useMigrations() // Load migrations from database/migrations
->withCommands([ // Register command classes
\Slice\Order\Console\SyncOrders::class,
])
}
use FullSmack\LaravelSlice\Slice;
use FullSmack\LaravelSlice\Extension;
final class CustomExtension implements Extension
{
public function register(Slice $slice): void
{
// Add custom functionality here
// Access to slice configuration, paths, etc.
// Example: Register Livewire or other frontend assets in your slice
}
}
use FullSmack\LaravelSlice\Slice;
use FullSmack\LaravelSlice\SliceServiceProvider;
final class OrderServiceProvider extends SliceServiceProvider
{
public function configure(Slice $slice): void
{
$slice->setName('order')
->withExtension(new CustomExtension())
->withExtension(new AnotherExtension());
}
}
use FullSmack\LaravelSlice\Testing\RefreshSliceDatabase;
final class RecipeTest extends TestCase
{
use RefreshSliceDatabase;
protected function setUp(): void
{
parent::setUp();
$this->refreshSlice('pizza');
}
}