Repository navigation
Starter Kits
Laravex ships three opt-in starter kits that scaffold boilerplate for common features. All are invoked via Artisan's install:* commands, implemented in Laravex.Install.
Scaffolds a minimal API layer with bearer-token authentication.
./artisan install:api
./artisan migrateWhat it creates:
-
routes/api.ex— Registers aGET /api/userroute under theapimiddleware group that authenticates via a bearer token and returns the user'sid,email, andnameas JSON (or 401 if unauthenticated).
Route group:
Router.group([prefix: "api", middleware: ["api"]], fn ->
Router.get("/user", fn request ->
user =
case Laravex.Http.Request.bearer_token(request) do
nil -> nil
token -> Laravex.Auth.Token.find_user(token)
end
if user do
Laravex.Http.Response.json(%{id: user.id, email: user.email, name: user.name})
else
Laravex.Http.Response.json(%{message: "Unauthenticated."}, 401)
end
end)
end)The routes/api.ex module is auto-registered on application boot once compiled. The api middleware group applies ThrottleRequests and SubstituteBindings (no session or CSRF).
After migrating, issue a token in IEx or a seeder:
token = Laravex.Auth.Token.create(user, "my-app", ["*"])
plain = token["plainTextToken"]Send it with every API request:
Authorization: Bearer <plain-token>
See API-Tokens for the full token API.
Scaffolds the broadcasting channel authorization layer.
./artisan install:broadcastingWhat it creates:
-
routes/channels.ex— Channel authorization file (equivalent to Laravel'sroutes/channels.php) -
config/broadcasting.exs— Broadcasting driver configuration
routes/channels.ex:
defmodule Routes.Channels do
def register do
Laravex.Broadcasting.Channel.channel(
"App.Models.User.{id}",
fn user, %{"id" => id} ->
not is_nil(user) and to_string(user.id) == to_string(id)
end
)
:ok
end
endconfig/broadcasting.exs:
%{
"default" => Laravex.Env.get("BROADCAST_CONNECTION", "log"),
"connections" => %{
"log" => %{"driver" => "log"},
"null" => %{"driver" => "null"},
"reverb" => %{"driver" => "reverb"},
"pusher" => %{"driver" => "pusher"},
"ably" => %{"driver" => "ably"}
}
}Set BROADCAST_CONNECTION in .env to switch drivers.
Scaffolds a complete session-based authentication flow with login, forgot password, and reset password.
./artisan install:starter-kit
./artisan migrateWhat it creates:
| Path | Description |
|---|---|
resources/views/auth/login.blade.php |
Login form with remember-me checkbox |
resources/views/auth/forgot_password.blade.php |
Forgot password form |
resources/views/auth/reset_password.blade.php |
Reset password form |
app/Http/Controllers/auth_controller.ex |
App.Http.Controllers.AuthController |
routes/auth.ex |
Auth routes registered as Routes.Auth
|
Routes registered (routes/auth.ex):
| Method | Path | Name | Action |
|---|---|---|---|
| GET | /login |
login |
Show login form |
| POST | /login |
— | Attempt login |
| POST | /logout |
— | Logout |
| GET | /forgot-password |
password.request |
Show forgot form |
| POST | /forgot-password |
password.email |
Send reset link |
| GET | /reset-password/{token} |
password.reset |
Show reset form |
| POST | /reset-password |
password.update |
Process reset |
AuthController highlights:
-
login/1callsLaravex.Auth.Guard.attempt/2; on success redirects to/, on failure re-flashes errors — see Authentication -
send_reset/1callsLaravex.Auth.Password.send_reset_link/1— see Passwords -
reset/1callsLaravex.Auth.Password.reset/1and validates withrequired|confirmed|min:8
Routes.Auth is auto-discovered and registered by Laravex.Foundation.Application.register_http_routes/1.
- Authentication — Guard, session, and middleware details
-
API-Tokens —
install:apiand bearer token lifecycle -
Passwords —
install:starter-kitreset-password flow
Laravex — Laravel-faithful application skeleton & runtime for Elixir.
GitHub
·
Docs
·
Limitations
·
Laravel Docs
Not affiliated with Laravel LLC or the Elixir core team. Built to feel like Laravel on the BEAM.
- Home
- Installation
- Configuration
- Directory-Structure
- Request-Lifecycle
- Service-Container
- Service-Providers
- Deployment
- Routing
- Middleware
- CSRF-Protection
- Controllers
- Requests
- Responses
- Views
- Blade-Templates
- Asset-Bundling
- Session
- Validation
- Error-Handling
- Logging
- Artisan-Console
- Broadcasting
- Cache
- Collections
- Events
- File-Storage
- Helpers
- HTTP-Client
- Localization
- Notifications
- Pipeline
- Queues
- Rate-Limiting
- Strings
- Task-Scheduling