Import & Export

Exporting Code

Exporting Code from Stellify

Export your Stellify projects as production-ready PHP files, ready to deploy to any Laravel-compatible hosting environment.

Overview

Stellify stores code as structured data in the database. When you export, it generates:

  • Clean, formatted PHP files
  • Laravel directory structure
  • Configuration files
  • Ready-to-deploy codebase

Export Methods

1. Web Interface Export

Single File Export

  1. Open a file in the Code Editor
  2. Click Export button in toolbar
  3. Choose format:
    • PHP File - Single .php file
    • With Dependencies - Includes use statements
  4. Download file

Result: A .php file ready to add to your project.

Project Export

  1. Navigate to Project Settings
  2. Click Export Project
  3. Choose what to export:
    • ☑ Controllers
    • ☑ Models
    • ☑ Routes
    • ☑ Config files
    • ☑ Migrations
    • ☐ Views (optional)
  4. Click Generate Export
  5. Download ZIP file

Result: Complete Laravel project structure in a ZIP file.

2. API Export

Use the export API endpoint for programmatic exports.

Export Single File

curl -X GET https://api.stellisoft.com/api/code/{file_uuid}/export \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json"

Response:

{
  "filename": "UserController.php",
  "content": "<?php\n\nnamespace App\\Http\\Controllers;\n\n..."
}

Export Full Project

curl -X POST https://api.stellisoft.com/api/projects/{project_id}/export \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"format": "laravel", "include": ["controllers", "models", "routes"]}'

Response: ZIP file download

3. CLI Export

Use the Stellify CLI for local exports.

stellify export --project=PROJECT_ID --output=./my-project

See CLI Documentation for full details.

Export Formats

Standard Laravel Structure

Default export creates:

my-project/
├── app/
│   ├── Http/
│   │   └── Controllers/
│   │       ├── Controller.php
│   │       ├── UserController.php
│   │       └── PostController.php
│   ├── Models/
│   │   ├── User.php
│   │   ├── Post.php
│   │   └── Comment.php
│   └── Services/
│       └── EmailService.php
├── config/
│   ├── database.php
│   ├── filesystems.php
│   └── app.php
├── database/
│   └── migrations/
│       └── 2024_01_01_000000_create_users_table.php
├── routes/
│   ├── web.php
│   └── api.php
├── composer.json
└── README.md

Selective Export

Export only specific components:

Controllers Only:

app/
└── Http/
    └── Controllers/
        ├── UserController.php
        └── PostController.php

Models Only:

app/
└── Models/
    ├── User.php
    └── Post.php

What Gets Exported

Controllers

Generated controller files include:

<?php

namespace App\Http\Controllers;

use App\Models\User;
use Illuminate\Http\Request;

class UserController extends Controller
{
    /**
     * Display a listing of users.
     */
    public function index()
    {
        $users = User::all();
        return view('users.index', ['users' => $users]);
    }

    /**
     * Store a newly created user.
     */
    public function store(Request $request)
    {
        $validated = $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|email|unique:users'
        ]);

        $user = User::create($validated);

        return redirect()->route('users.show', $user);
    }
}

Features:

  • Proper namespace declarations
  • All use statements
  • PHPDoc comments
  • PSR-12 formatting
  • Type hints preserved

Models

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class User extends Model
{
    /**
     * The attributes that are mass assignable.
     */
    protected $fillable = [
        'name',
        'email',
        'password',
    ];

    /**
     * The attributes that should be hidden.
     */
    protected $hidden = [
        'password',
        'remember_token',
    ];

    /**
     * Get the posts for the user.
     */
    public function posts(): HasMany
    {
        return $this->hasMany(Post::class);
    }
}

Features:

  • All properties ($fillable, $casts, $hidden)
  • Relationships with return types
  • Accessors and mutators
  • Scopes

Routes

routes/web.php:

<?php

use App\Http\Controllers\UserController;
use App\Http\Controllers\PostController;
use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Route::resource('users', UserController::class);
Route::resource('posts', PostController::class);

Route::middleware(['auth'])->group(function () {
    Route::get('/dashboard', [DashboardController::class, 'index'])->name('dashboard');
});

Features:

  • Resource routes
  • Named routes
  • Middleware groups
  • Proper formatting

Configuration Files

config/database.php:

<?php

return [
    'default' => env('DB_CONNECTION', 'mysql'),

    'connections' => [
        'mysql' => [
            'driver' => 'mysql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
        ],
    ],
];

Features:

  • Environment variables
  • Proper defaults
  • Laravel conventions

Migrations

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('users', function (Blueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('users');
    }
};

Export Options

Code Style

Choose formatting style:

PSR-12 (default):

class UserController extends Controller
{
    public function index()
    {
        return view('users.index');
    }
}

Laravel Style:

class UserController extends Controller {

    public function index() {
        return view('users.index');
    }
}

Set in export options or project settings.

Documentation Level

Minimal:

  • No PHPDoc blocks
  • Only essential comments

Standard (default):

  • PHPDoc for public methods
  • Property documentation
  • Class descriptions

Comprehensive:

  • Full PHPDoc for all methods
  • Parameter descriptions
  • Return type documentation
  • @throws annotations

Environment Files

Export generates .env.example:

APP_NAME=Stellify
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=stellify
DB_USERNAME=root
DB_PASSWORD=

# Add your actual values to .env

Post-Export Setup

1. Install Dependencies

cd my-project
composer install

2. Configure Environment

cp .env.example .env
php artisan key:generate

Edit .env with your settings:

DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password

3. Run Migrations

php artisan migrate

4. Test Application

php artisan serve

Visit http://localhost:8000

Continuous Export

Automated Exports

Set up automatic exports on code changes.

GitHub Integration

  1. Connect GitHub in Stellify settings
  2. Choose repository and branch
  3. Enable auto-export
  4. Commit message template: [Stellify] Update {filename}

Result: Every save in Stellify pushes to GitHub.

Webhook Export

Configure webhook to trigger export:

POST https://your-server.com/webhook/stellify-export
{
  "project_id": "uuid",
  "event": "code.updated",
  "files": ["UserController.php"]
}

Your server can then:

  • Pull exported code
  • Run tests
  • Deploy automatically

Scheduled Exports

Export on a schedule:

  1. Go to Project Settings → Exports
  2. Enable scheduled exports
  3. Choose frequency (daily, weekly)
  4. Set destination (email, FTP, S3)

Export to Different Environments

Development

stellify export --env=development --debug=true

Includes:

  • Debug statements
  • Detailed logging
  • Test helpers

Staging

stellify export --env=staging

Includes:

  • Error handling
  • Logging
  • Performance monitoring

Production

stellify export --env=production --optimize

Includes:

  • Optimized code
  • Caching
  • Security hardening
  • Removed debug code

Deployment Workflows

Workflow 1: Manual Deploy

  1. Export from Stellify
  2. Download ZIP file
  3. Extract to local directory
  4. Run composer install
  5. Configure .env
  6. Upload to server via FTP/SFTP
  7. Run php artisan migrate on server

Workflow 2: Git Deploy

  1. Export to GitHub (auto or manual)
  2. Pull on server: git pull origin main
  3. Install dependencies: composer install --no-dev
  4. Migrate: php artisan migrate --force
  5. Optimize: php artisan optimize

Workflow 3: CI/CD Pipeline

  1. Stellify exports to GitHub on save
  2. GitHub Actions triggers:
    • Run tests
    • Build assets
    • Deploy to staging
  3. Manual approval for production
  4. Deploy to production servers

Example GitHub Action:

name: Deploy from Stellify

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Install dependencies
        run: composer install --no-dev --optimize-autoloader
      - name: Run tests
        run: php artisan test
      - name: Deploy
        run: ./deploy.sh

Export Validation

Pre-Export Checks

Stellify validates before export:

  • ✅ Syntax errors
  • ✅ Missing dependencies
  • ✅ Namespace conflicts
  • ✅ Required methods

Post-Export Verification

After export, verify:

# Check syntax
find . -name "*.php" -exec php -l {} \;

# Run tests
php artisan test

# Check PSR compliance
./vendor/bin/phpcs

Troubleshooting

Export Fails

Error: Missing dependencies

  • Import required classes first
  • Or use partial export for specific files

Error: Syntax error in generated code

  • Report bug to Stellify support
  • Export individual files to identify issue

Incomplete Export

Some files missing:

  • Check export options
  • Verify file permissions in Stellify
  • Review export logs

Performance Issues

Export takes too long:

  • Export in batches
  • Use selective export
  • Schedule exports during off-peak

Best Practices

Before Export

  1. Test code - Run methods in Stellify
  2. Check dependencies - Ensure all imports work
  3. Review configuration - Verify settings
  4. Commit changes - If using version control

During Export

  1. Choose right format - Match your target environment
  2. Select what you need - Don't export everything
  3. Check file list - Review what will be exported

After Export

  1. Install dependencies - Run composer install
  2. Configure environment - Set up .env
  3. Run migrations - Update database
  4. Test thoroughly - Verify everything works
  5. Deploy - Push to production

Command Reference

Web Interface

Project Settings → Export Project
├─ Format: Laravel
├─ Include:
│  ├─ ☑ Controllers
│  ├─ ☑ Models
│  ├─ ☑ Routes
│  ├─ ☑ Config
│  └─ ☑ Migrations
└─ Generate Export → Download ZIP

API

POST /api/projects/{id}/export
{
  "format": "laravel",
  "include": ["controllers", "models", "routes"],
  "style": "psr12",
  "env": "production"
}

CLI

stellify export \
  --project=PROJECT_ID \
  --output=./output \
  --format=laravel \
  --env=production

Next Steps


Ready to deploy? Export your project and follow the Deployment Guide.

Please be aware that our documentation is under construction.