GitHub - pihedy/laravel-cobol

GitHub

9 min read Original article ↗

Laravel for COBOL

The COBOL framework for ambitious applications.

COBOL since 1959 Build: batch job queued Mainframe ready AI-first Understanding: optional License: MIT

Ship confidently. Understand optionally.

About · Why COBOL? · A Taste · Getting Started · Performance · Roadmap · Contributing

Laravel for COBOLLaravel (PHP)
Requests / sec80137
p99 latency🏆 ~250 ms~700 ms
Lines of code per endpoint🏆 1881

Same $5 VPS budget: 1 vCPU, 1 GB RAM. Full benchmark · Run it yourself: ./cobtisan benchmark

🧩 Part of the movement: Laravel COBOL is proudly listed in
Laravel for Laravel Ports, the collection of Laravel ports nobody asked for.
Rust, Go, COBOL, BASIC… and now emoji. Go see the others. 😁


Important

Laravel for COBOL is an unofficial, satirical project. It is not affiliated with, endorsed by, or connected to Laravel or Laravel Holdings Inc. "Laravel" is used here purely for parody and commentary.


About Laravel for COBOL

Software development is changing. As AI agents become increasingly capable of writing and maintaining application code, the programming language itself is becoming less relevant. Developers no longer need to understand every line of code their applications execute.

Naturally, we asked ourselves: why stop at Rust or Go?

Laravel for COBOL is a modern, AI-first, full-stack web framework built on over six decades of proven enterprise technology. It brings the expressive developer experience you know and love to a language that has been quietly running the world's money since before the moon landing.

Why COBOL?

While other programming languages are still establishing their place in enterprise environments, COBOL has been successfully processing critical financial transactions since 1959.

We believe that the future of software development deserves a language with a proven past.

By combining Laravel's expressive development philosophy with COBOL's enterprise-grade architecture, we're bringing modern developer experiences to a generation of technology that never asked for them.

PHP COBOL
First released 1995 1959
Runs the world's banks Occasionally Yes
Uppercase keywords Optional Mandatory, and proudly so
Line length Unlimited 72 columns, as nature intended
Lines of code per route ~1 ~40
Context for your AI agent Limited Abundant

Built for the AI era

Historically, COBOL's verbosity has been considered a disadvantage. With modern AI agents, we believe this is no longer a limitation.

In fact, generating thousands of lines of COBOL instead of hundreds of lines of PHP provides AI agents with significantly more context to reason about.

You focus on your ideas. Your agent focuses on the implementation. Someone else can focus on maintaining it.

Everything you love about Laravel

Laravel for COBOL aims to deliver the familiar Laravel experience:

  • 🛣️ Expressive routing — declared in the PROCEDURE DIVISION, where it belongs
  • 🗄️ Eloquent ORM — with native IBM DB2 integration
  • 📦 Enterprise-grade batch processing — queues are just batch jobs with better marketing
  • 🧩 Dependency injection — via CALL ... USING, the original service container
  • 🔐 Authentication and authorization — RACF-compatible, naturally
  • 🤖 AI-powered development workflows — the only way anyone will write this
  • 🏢 First-class mainframe deployment — z/OS is our Forge
  • 🕰️ Backward compatibility — with technology older than most developers

A taste of Laravel for COBOL

Routing

      *> routes/WEB.cbl
       IDENTIFICATION DIVISION.
       PROGRAM-ID. WEB-ROUTES.

       PROCEDURE DIVISION.
           CALL 'ROUTE-GET' USING BY CONTENT '/'
                                  BY CONTENT 'WELCOME-CONTROLLER'
                                  BY CONTENT 'INDEX'.

           CALL 'ROUTE-GET' USING BY CONTENT '/users/{id}'
                                  BY CONTENT 'USER-CONTROLLER'
                                  BY CONTENT 'SHOW'.

           CALL 'ROUTE-POST' USING BY CONTENT '/users'
                                   BY CONTENT 'USER-CONTROLLER'
                                   BY CONTENT 'STORE'.
           GOBACK.

Route middleware is fluent, if you squint:

      *> routes/API.cbl
           CALL 'ROUTE-GET' USING BY CONTENT '/api/users/{id}'
                                  BY CONTENT 'API-USER-CONTROLLER'
                                  BY CONTENT 'SHOW'.
           CALL 'ROUTE-MIDDLEWARE' USING BY CONTENT 'AUTH'.

Eloquent models

The schema is the copybook, and the copybook is the schema:

      *> app/Models/USER-RECORD.cpy
       01  USER-RECORD.
           05  USER-ID                PIC 9(9).
           05  USER-NAME              PIC X(60).
           05  USER-EMAIL             PIC X(120).
           05  USER-CREATED-AT        PIC X(26).
      *> User::find($id)
           CALL 'USER-MODEL' USING BY CONTENT 'FIND'
                                   BY REFERENCE MODEL-STATUS
                                   USER-RECORD

MODEL-STATUS is a real VSAM file status: '00' is fine, '23' is a ModelNotFoundException, and '35' means you forgot to migrate. The default driver stores data in GnuCOBOL indexed files. The DB2 driver is with an agent.

Controllers

      *> app/Http/Controllers/USER-CONTROLLER.cbl
       PROCEDURE DIVISION USING REQUEST RESPONSE.
      *> PHP has method dispatch. We have EVALUATE.
       DISPATCH.
           EVALUATE REQ-ACTION
               WHEN 'INDEX' PERFORM INDEX-ACTION
               WHEN 'SHOW'  PERFORM SHOW-ACTION
               WHEN 'STORE' PERFORM STORE-ACTION
           END-EVALUATE
           GOBACK.

       SHOW-ACTION.
           CALL 'REQUEST-INPUT' USING REQUEST BY CONTENT 'id'
                                      BY REFERENCE WS-ID-IN
           ...
           CALL 'VIEW-RENDER' USING BY CONTENT 'users.show'
                                    BY REFERENCE VIEW-DATA RESPONSE.

Tip

The PHP equivalent of the full controller is about fifteen lines long. Ours is 188. We consider this a feature.

Middleware

Every middleware gets called twice: once BEFORE the controller and once AFTER, in reverse order. It's an onion, built from a PERFORM VARYING.

      *> app/Http/Middleware/MAINFRAME-HEADERS.cbl
       PROCEDURE DIVISION USING REQUEST RESPONSE MW-CONTROL.
           IF MW-AFTER
               CALL 'RESPONSE-HEADER' USING RESPONSE
                   BY CONTENT 'X-Powered-By: COBOL-85'
           END-IF
           GOBACK.

Built in: AUTH (RACF-compatible: send X-RACF-User: IBMUSER), VERIFY-CSRF-TOKEN (@csrf works in Blade) and MAINFRAME-HEADERS.

Blade

<td>{{ USER-NAME }}</td>   <!-- escaped -->
{!! ROWS !!}               <!-- raw -->
@csrf

Errors

abort() is called ABEND, and the error page shows a storage dump.

You did You get
GET /users/abc ABEND S0C7 Data exception
Route a missing controller ABEND S806 Module not found
Forget @csrf 419 Page expired

Cobtisan

./cobtisan serve                    # docker compose up
./cobtisan route:list
./cobtisan make:controller POST     # 58 lines. You're welcome.
./cobtisan make:middleware LOG-REQUEST
./cobtisan migrate:fresh --seed     # IEFBR14 says hello
./cobtisan test
./cobtisan lint                     # fails past column 72
./cobtisan inspire
./cobtisan about
./cobtisan benchmark                # vs. Laravel (PHP), see Performance

Getting started

Requirements

Component Supported
Runtime Docker. The image brings GnuCOBOL 3.1 and lighttpd
Compiler GnuCOBOL 3.1+ (IBM Enterprise COBOL: planned)
Database VSAM-style indexed files. IBM DB2: planned
Operating system z/OS, Linux, Windows, "whatever the bank has"
Terminal Any. IBM 3270 for the authentic experience
Patience Required

Installation

You need Docker (with Docker Compose) and Git. You don't need a COBOL compiler: the image includes one. On Windows, run the commands from Git Bash or WSL.

  1. Clone the repository:

    git clone https://github.com/<your-org>/laravel-cobol.git my-app
    cd my-app
  2. Optional: if port 8000 is already taken, create .env and pick another port:

    cp .env.example .env
    # then edit: APP_PORT=8070
  3. Start the server:

    On first start, the container creates .env if it doesn't exist, generates APP_KEY, compiles every program, migrates and seeds. The first build takes a minute or two.

  4. Open http://localhost:8000 (or the port you set). The app may also be ready at the next scheduled batch window, whichever comes first.

  5. Optional: in a second terminal, check that everything works:

To stop the server, press Ctrl+C or run ./cobtisan down. After changing a .cbl file, run ./cobtisan build. You don't need to restart.

How it works

lighttpd hands every request to public/index.cgi, which starts the COBOL front controller (public/INDEX.cbl). One request is one process: a batch job with better marketing. Every other program is compiled into its own module under build/ and loaded on CALL, so the controller name in a route really is a dynamic CALL.

Directory structure

my-app/
├── app/
│   ├── Http/
│   │   ├── Controllers/       # *.cbl
│   │   ├── Middleware/        # *.cbl
│   │   └── KERNEL.cbl         # global middleware
│   └── Models/                # *.cbl and *.cpy copybooks
├── database/
│   ├── migrations/            # allocates the datasets
│   └── seeders/
├── framework/                 # what vendor/laravel would be, in COBOL
│   ├── copybooks/             # REQUEST, RESPONSE, ROUTES, VIEW-DATA...
│   └── src/                   # Routing, Http, View, Foundation, Console
├── public/
│   ├── INDEX.cbl              # the front controller
│   └── index.cgi
├── resources/
│   └── views/                 # *.blade.html (BMS map support planned)
├── routes/
│   ├── WEB.cbl
│   └── API.cbl
├── storage/logs/SYSOUT.log    # one IEF403I line per request
├── stubs/                     # make:* templates
├── tests/Feature/             # run with ./cobtisan test
└── cobtisan

Performance

Our preliminary benchmarks demonstrate promising results when running a minimal application on dedicated enterprise mainframe infrastructure.

Setup Requests / sec Monthly cost
Laravel for COBOL on IBM z16 Very many Please call sales
Laravel (PHP) on a $5 shared VPS See below $5

Since the mainframe is still with sales, we did the next best thing: we gave both frameworks the same $5 VPS budget (1 vCPU, 1 GB RAM, in Docker) and the same two endpoints. Laravel is a stock install in production mode: opcache on, everything cached.

Endpoint Laravel for COBOL Laravel (PHP)
GET /users/1 80 req/s 137 req/s
GET /api/users/1 137 req/s 158 req/s
p99 latency ~195–300 ms ~570–790 ms
Lines of code 188 1

PHP is faster on average. COBOL has two to three times better tail latency, while starting a new process for every single request. Sixty years of batch processing teach you consistency.

Run it yourself with ./cobtisan benchmark. The setup is in benchmarks/, and each run writes its numbers to benchmarks/RESULTS.md. Results vary by machine and by run.

Roadmap

Laravel for COBOL is currently in early development. While some features are not yet implemented, our AI agents are working hard to close the gap between announced functionality and existing functionality.

Feature Status
This README ✅ Shipped
Expressive routing ✅ Shipped
Middleware ✅ Shipped
Eloquent ORM (VSAM driver) ✅ Shipped
Blade templating ({{ }}, @csrf) ✅ Shipped
RACF-compatible authentication ✅ Shipped, loosely
Eloquent ORM (DB2 driver) 🤖 Agent assigned
@foreach, @if 🤖 Agent assigned
make:model 🤖 Agent assigned
Queues (as JCL batch jobs) 🗓️ Planned
Livewire for 3270 terminals 💭 Under consideration
Understanding the codebase 🚫 Not on the roadmap

Agentic development

Laravel for COBOL is designed to be written by AI agents from day one. For the best results:

  1. Describe what you want in plain language.
  2. Let your agent generate the IDENTIFICATION, ENVIRONMENT, DATA and PROCEDURE divisions.
  3. Commit with confidence.
  4. Do not read the diff. It is very long.

Philosophy

We believe that developers should never be limited by their choice of programming language, their understanding of the underlying technology, or the long-term maintainability of their applications.

The future of web development started in 1959.

Contributing

Thank you for considering contributing to Laravel for COBOL! Pull requests are welcome, especially those written by humans who can still read COBOL. Please:

  • Keep code within columns 8–72.
  • Write keywords in UPPERCASE. All of them.
  • Open an issue first for larger changes, so we can schedule a batch window to discuss it.

Code of Conduct

Be kind and respectful to everyone — including the COBOL developers who were doing this before any of us were born.

Security Vulnerabilities

If you discover a security vulnerability in Laravel for COBOL, please report it privately through GitHub Security Advisories rather than opening a public issue. All security vulnerabilities will be promptly addressed, within the next available batch window.

License

Laravel for COBOL is open-sourced software licensed under the MIT license.


Laravel for COBOL. Ship confidently. Understand optionally.

Laravel for COBOL is an unofficial satirical project and is not affiliated with Laravel or Laravel Holdings Inc.