mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 00:01:21 +00:00
6.3 KiB
6.3 KiB
Smarty 4 to Laravel Blade + TailwindCSS Migration Guide
Overview
This document provides a comprehensive guide for migrating the NNTmux application from Smarty 4 templates to Laravel Blade with TailwindCSS.
Changes Made
1. New Blade Layouts Created
resources/views/layouts/main.blade.php- Main application layoutresources/views/layouts/admin.blade.php- Admin panel layoutresources/views/layouts/app.blade.php- Existing Laravel auth layout (retained)
2. New Blade Partials Created
resources/views/partials/header-menu.blade.php- Top navigation menuresources/views/partials/sidebar.blade.php- Left sidebar navigationresources/views/partials/footer.blade.php- Footer contentresources/views/partials/admin-menu.blade.php- Admin sidebar menu
3. New Blade Views Created
resources/views/browse/index.blade.php- Browse releases pageresources/views/details/index.blade.php- Release details pageresources/views/home/index.blade.php- Home page template
4. Controllers Updated
The following controllers have been migrated from Smarty to Blade:
BasePageController.php- Base controller (removed Smarty, added Blade support)BrowseController.php- Browse functionalityDetailsController.php- Release details
Migration Pattern
Before (Smarty):
public function index(Request $request)
{
$this->setPreferences();
// Business logic...
$this->smarty->assign('data', $data);
$this->smarty->assign('meta_title', 'Page Title');
$content = $this->smarty->fetch('template.tpl');
$this->smarty->assign(compact('content', 'meta_title'));
$this->pagerender();
}
After (Blade):
public function index(Request $request)
{
$this->setPreferences();
// Business logic...
$this->viewData = array_merge($this->viewData, [
'data' => $data,
'meta_title' => 'Page Title',
]);
return view('module.index', $this->viewData);
}
Template Syntax Migration
Variables
Smarty:
{$variable}
{$user.name}
Blade:
{{ $variable }}
{{ $user->name }}
Conditionals
Smarty:
{if $condition}
Content
{elseif $other}
Other
{else}
Default
{/if}
Blade:
@if($condition)
Content
@elseif($other)
Other
@else
Default
@endif
Loops
Smarty:
{foreach $items as $item}
{$item.name}
{/foreach}
Blade:
@foreach($items as $item)
{{ $item->name }}
@endforeach
URLs and Routes
Smarty:
{{url('/browse/All')}}
{{route('series')}}
Blade:
{{ url('/browse/All') }}
{{ route('series') }}
Authentication
Smarty:
{if Auth::check()}
Logged in content
{/if}
Blade:
@auth
Logged in content
@endauth
@guest
Guest content
@endguest
Including Partials
Smarty:
{include file='sidebar.tpl'}
Blade:
@include('partials.sidebar')
TailwindCSS Integration
Styling Philosophy
- Replace Bootstrap classes with TailwindCSS utility classes
- Use responsive prefixes (sm:, md:, lg:, xl:)
- Utilize Tailwind's color palette and spacing system
Common Class Conversions
| Bootstrap | TailwindCSS |
|---|---|
container |
container mx-auto px-4 |
row |
flex flex-wrap or grid |
col-md-6 |
md:w-1/2 or md:col-span-6 |
btn btn-primary |
px-4 py-2 bg-blue-600 text-white rounded |
text-center |
text-center |
mb-3 |
mb-3 (Tailwind uses same spacing scale) |
d-flex |
flex |
justify-content-between |
justify-between |
align-items-center |
items-center |
Remaining Work
Controllers to Update
All remaining controllers in app/Http/Controllers/ need to be migrated:
- SearchController.php
- MovieController.php
- SeriesController.php
- ProfileController.php
- CartController.php
- Admin/* controllers
- And many more...
Templates to Create
Convert all .tpl files from resources/views/themes/ to .blade.php:
- Admin templates
- Search templates
- Movie/TV templates
- Profile templates
- Forum templates
- etc.
Steps for Each Controller Migration
-
Update the controller method:
- Remove
$this->smarty->assign()calls - Replace with
$this->viewData = array_merge() - Change
$this->pagerender()toreturn view('view.name', $this->viewData)
- Remove
-
Create corresponding Blade view:
- Copy relevant HTML from
.tplfile - Convert Smarty syntax to Blade syntax
- Replace Bootstrap classes with TailwindCSS
- Ensure proper use of
@extendsand@section
- Copy relevant HTML from
-
Test thoroughly:
- Verify all data displays correctly
- Check responsive design
- Test user interactions
- Validate forms and AJAX calls
Configuration Changes
Remove Smarty Package (After Migration Complete)
Once all templates are migrated, you can remove the Smarty dependency:
composer remove smarty/smarty ytake/laravel-smarty
Remove from config/app.php:
- Smarty service provider entries
Delete:
config/ytake-laravel-smarty.php
Benefits of This Migration
- Better Laravel Integration - Blade is Laravel's native templating engine
- Performance - Blade compiles to plain PHP and is cached
- Modern UI - TailwindCSS provides utility-first CSS framework
- Maintainability - Standard Laravel conventions
- Developer Experience - Better IDE support and debugging
- Security - Automatic XSS protection with Blade's
{{ }}syntax
Testing Checklist
- Authentication works (login/logout)
- Browse pages display correctly
- Release details show all information
- Search functionality works
- Admin panel is accessible
- Forms submit properly
- AJAX requests function
- Responsive design on mobile
- All routes resolve correctly
- No JavaScript errors in console
Notes
- The
BasePageControllernow uses$viewDataarray instead of Smarty assignments - All views should extend
layouts.mainorlayouts.admin - Use
@stackand@pushfor page-specific scripts/styles - TailwindCSS config is in
tailwind.config.js - Vite is configured for asset compilation
Support
For questions or issues during migration, refer to: