Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Alphalemon Cms Bundle Laravel Package

alphalemon/alphalemon-cms-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup for Laravel Integration

Since AlphaLemon CMS is built for Symfony2, direct Laravel integration is not natively supported. However, you can leverage its core features (Propel ORM, theming, and CMS logic) by:

  1. Installing Propel in Laravel

    composer require propel/propel1 propel/propel-bundle
    

    Configure Propel in config/app.php and run migrations:

    php artisan propel:build --all
    php artisan propel:migrate
    
  2. Extracting AlphaLemon’s Core Logic

    • Clone the AlphaLemonCmsSandbox and inspect:
      • src/AlphaLemon/CmsBundle/ for Propel schemas (schema.xml).
      • src/AlphaLemon/ThemeEngineBundle/ for templating logic.
    • Replicate Propel models and behaviors in Laravel using:
      php artisan make:model Page -m --propel
      
  3. First Use Case: Basic CMS Page Management

    • Create a Page model with Propel behaviors (e.g., VersionableBehavior).
    • Use the AlphaLemon-style admin UI by:
      • Forking AlphaLemon’s Bootstrap Bundle and adapting it for Laravel.
      • Implementing a custom admin controller:
        // app/Http/Controllers/Admin/PagesController.php
        public function index() {
            $pages = PageQuery::create()->find();
            return view('admin.pages.index', compact('pages'));
        }
        

Implementation Patterns

1. Propel ORM Integration

  • Schema Inheritance: AlphaLemon uses Propel’s XML schemas. Convert these to Laravel migrations:

    <!-- AlphaLemon schema.xml snippet -->
    <table name="alcms_page" phpName="Page">
        <column name="title" type="VARCHAR" size="255" required="true" />
        <behavior name="versionable" />
    </table>
    

    → Laravel migration:

    Schema::create('pages', function (Blueprint $table) {
        $table->string('title')->unique();
        $table->timestamps();
        // Add Propel versioning columns manually if needed
    });
    
  • Query Patterns:

    // AlphaLemon-style query (Propel)
    $pages = PageQuery::create()
        ->filterByPublished(true)
        ->orderByTitle()
        ->find();
    
    // Laravel equivalent (Eloquent)
    $pages = Page::where('published', true)->orderBy('title')->get();
    

2. Theming System

  • AlphaLemon uses a theme engine with blocks (header, footer, content). Adapt this in Laravel:
    // app/Services/ThemeService.php
    public function render($theme, $blocks) {
        return view("themes.$theme.layout", compact('blocks'));
    }
    
    • Store themes in resources/themes/ and use Blade templates.

3. Admin Panel Workflow

  • Reuse AlphaLemon’s UI Components:

    • Fork AlphaLemonBootstrapBundle and replace Symfony dependencies with Laravel’s.
    • Example: Convert a Symfony form to Laravel Collective:
      // AlphaLemon (Symfony)
      $form = $this->createForm(new PageType(), $page);
      
      // Laravel
      use Illuminate\Support\Facades\Validator;
      $validator = Validator::make($request->all(), [
          'title' => 'required|string',
      ]);
      
  • CRUD Boilerplate: Use Laravel’s generators to mirror AlphaLemon’s admin structure:

    php artisan make:controller Admin/PagesController --resource --model=Page
    

4. Media Management

  • AlphaLemon uses ElFinderBundle. Replace with Laravel’s spatie/laravel-medialibrary:
    // AlphaLemon (Symfony)
    $finder = $this->get('elfinder')->getFinder();
    
    // Laravel
    use Spatie\MediaLibrary\HasMedia;
    class Page extends Model implements HasMedia {
        public function registerMediaCollections(): void {
            $this->addMediaCollection('images');
        }
    }
    

Gotchas and Tips

1. Propel vs. Eloquent Quirks

  • Pitfall: Propel’s VersionableBehavior requires manual column setup in Laravel:
    Schema::create('pages', function (Blueprint $table) {
        $table->string('title');
        $table->integer('version')->default(1); // Add this!
        $table->json('version_data'); // For storing revisions
    });
    
  • Tip: Use willdurand/propel-typehintable-behavior for better IDE support in Laravel.

2. Theming Conflicts

  • Pitfall: AlphaLemon’s theme engine assumes Symfony’s Twig_Environment. In Laravel:
    • Override the theme service to use Laravel’s View facade:
      public function render($theme, $blocks) {
          return view("themes.$theme.layout", compact('blocks'))
              ->render();
      }
      
  • Tip: Use Laravel Mix to compile theme assets:
    // webpack.mix.js
    mix.setPublicPath('public/themes')
        .js('resources/themes/js/app.js', 'js')
        .sass('resources/themes/scss/app.scss', 'css');
    

3. Admin Panel Integration

  • Pitfall: AlphaLemon’s backend routes use Symfony’s routing.yml. Convert to Laravel:
    # AlphaLemon routing.yml
    alcms_backend:
        resource: "@AlphaLemonCmsBundle/Resources/config/routing.yml"
        prefix: /backend
    
    → Laravel routes/web.php:
    Route::prefix('backend')->name('alcms.')->group(function () {
        Route::resource('pages', \App\Http\Controllers\Admin\PagesController::class);
    });
    
  • Tip: Use Laravel’s middleware for auth:
    Route::middleware(['auth', 'admin'])->group(function () {
        // Admin routes
    });
    

4. Debugging Propel in Laravel

  • Pitfall: Propel’s debug mode (alcms_dev.php) won’t work directly. Instead:
    • Enable Propel logging in config/propel.php:
      'logging' => [
          'enabled' => true,
          'level' => 'debug',
      ],
      
    • Check logs in storage/logs/propel.log.

5. Extending AlphaLemon Features

  • Tip: To add custom fields (e.g., SEO metadata):
    1. Extend the Propel schema:
      <column name="meta_title" type="VARCHAR" size="255" />
      
    2. Add to Laravel migration and model:
      class Page extends Model {
          protected $fillable = ['meta_title'];
      }
      
    3. Update the admin form (use Laravel Collective or Livewire).

6. Performance Considerations

  • Pitfall: Propel’s lazy-loading can cause N+1 queries. In Laravel:
    • Use with() for eager loading:
      $pages = Page::with('author', 'media')->get();
      
    • For Propel, enable batch fetching:
      PageQuery::create()->enableBatchMode()->find();
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware