1{
2 "artifact": "model",
3 "class": "Subscriber",
4 "namespace": "App\\Models",
5 "table": "subscribers",
6 "has_factory": true,
7 "soft_deletes": false,
8 "fillable": ["email", "name", "status", "subscribed_at"],
9 "casts": {"subscribed_at": "datetime"},
10 "relationships": [],
11 "scopes": [{"name": "active", "column": "status", "value": "active"}]
12}
The model outputs the complete PHP file — no markdown, no explanations.
1from mlx_lm import load, generate
2
3model, tokenizer = load(
4 "mlx-community/Qwen2.5-Coder-7B-Instruct-4bit",
5 adapter_path="fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA-Spec"
6)
7
8SYSTEM = """You are a Laravel 13.x PHP code generator. Input is a BuildSpec JSON object. Output is the complete PHP file.
9
10Rules:
11- Output ONLY the PHP file. No markdown fences. No explanation.
12- artifact=model: ALWAYS add use HasFactory when has_factory=true. ONLY add relationship methods listed in relationships[].
13- artifact=controller: ALWAYS import App\\Http\\Controllers\\Controller and Illuminate\\Http\\Request. destroy() returns response()->noContent(). store() returns response()->json($resource, 201).
14- artifact=resource: ALWAYS import Illuminate\\Http\\Resources\\Json\\JsonResource. For EVERY entry in loaded_relations[] that has a "resource" key, add the use import.
15- artifact=form_request: If conditional_rules present, expand using $this->isMethod('POST') ternary or spread. For POST-only rules use spread: `...$this->isMethod('POST') ? ['rule'] : []`. authorize() returns true."""
16
17spec = {
18 "artifact": "model",
19 "class": "Post",
20 "namespace": "App\\Models",
21 "table": "posts",
22 "has_factory": True,
23 "fillable": ["title", "body", "user_id"],
24 "relationships": [
25 {"type": "BelongsTo", "model": "User", "method": "author", "foreign_key": "user_id"}
26 ]
27}
28
29import json
30msgs = [
31 {"role": "system", "content": SYSTEM},
32 {"role": "user", "content": json.dumps(spec, indent=2)},
33]
34prompt = tokenizer.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
35prompt += "<?php\n"
36result = generate(model, tokenizer, prompt=prompt, max_tokens=1000, verbose=False)
37print("<?php\n" + result)
1# NL → specs → compile → generate PHP files
2python3 pipeline_spec.py "Create a REST API for managing blog posts with tags"
Spec fixes are deterministic and compiler-catchable. Prompt fixes require runtime debugging.
1@misc{laravel-buildspec-2026,
2 author = {Florinel Chis},
3 title = {Laravel 13.x BuildSpec to Code LoRA Adapter},
4 year = {2026},
5 publisher = {Hugging Face},
6 url = {https://huggingface.co/fchis/Laravel-13x-Qwen2.5-Coder-7B-Instruct-LoRA-Spec}
7}