适用于 COBOL 的 Laravel
Laravel for COBOL

原始链接: https://github.com/pihedy/laravel-cobol

Laravel for COBOL 是一个非官方的、讽刺性的“现代、AI 优先”Web 框架,它通过把 Laravel 风格的开发方式带到 COBOL 中,戏仿 Laravel 的移植版。它宣称将 Laravel 富有表现力的路由、中间件、ORM、类似 Blade 的模板、认证和命令行工具,与 COBOL 大型机时代的冗长和企业级神秘感结合起来。路由和控制器使用 COBOL 的 division 和 CALL 编写;模型使用 copybook 和 VSAM 风格的索引文件,DB2 支持则“计划中”。该项目顺势拥抱 AI 生成代码:冗长的 COBOL 被包装成一种优势,因为它能给智能体提供更多上下文,同时鼓励开发者不要阅读变更差异。在 5 美元 VPS 上的基准测试显示,PHP Laravel 平均更快,但 COBOL 的尾部延迟更好,代码行数也多得多。环境搭建使用 Docker、GnuCOBOL 和 lighttpd,并提供 cobtisan serve、build、test 和 benchmark 等命令。README 概述了已提供的功能、队列和模型生成等计划中的功能、贡献规则、安全报告方式,以及明确声明其不隶属于 Laravel。

一篇 Hacker News 帖子分享了“Laravel for COBOL”,这是一个 GitHub 项目,以玩笑的方式将 Laravel 风格的约定引入 COBOL。评论者们既觉得好笑又带着怀旧情绪,称它为“COBOL 的最后一道余辉”,拿“cobbler”这样的名字以及未来移植到 Fortran 或汇编的想法开玩笑,并将它比作 Rails 之后的衍生项目,如“Cobol on Cogs”。一位评论者喜欢这样的想法:专注于想法,而由智能体负责实现和维护;另一位则指出路线图中的说明:“理解代码库”不在其中。总体而言,这个讨论串把该项目视为对老派编程文化的一次幽默致敬。
相关文章

原文
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.


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.

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

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

      *> 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'.

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.

      *> 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.

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.

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

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 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
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

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.

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.

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

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.

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

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.

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.

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.

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

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.

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.

联系我们 contact @ memedata.com