https://github.com/phoenix-playground/phoenix_playground
Phoenix Playground makes it easy to create single-file Phoenix applications.
https://github.com/phoenix-playground/phoenix_playground
elixir experiments phoenix prototyping
Last synced: 4 months ago
JSON representation
Phoenix Playground makes it easy to create single-file Phoenix applications.
- Host: GitHub
- URL: https://github.com/phoenix-playground/phoenix_playground
- Owner: phoenix-playground
- Created: 2024-03-28T10:05:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-16T08:36:37.000Z (about 1 year ago)
- Last Synced: 2024-06-02T16:27:44.326Z (about 1 year ago)
- Topics: elixir, experiments, phoenix, prototyping
- Language: Elixir
- Homepage:
- Size: 630 KB
- Stars: 39
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Phoenix Playground
[](https://github.com/phoenix-playground/phoenix_playground/actions/workflows/ci.yml)
[](https://hex.pm/packages/phoenix_playground)
[](https://hexdocs.pm/phoenix_playground)Phoenix Playground makes it easy to create single-file [Phoenix](https://www.phoenixframework.org) applications.
## Examples
[](https://livebook.dev/run?url=https%3A%2F%2Fgithub.com%2Fphoenix-playground%2Fphoenix_playground%2Fblob%2Fmain%2Fexamples%2Fdemo_live.livemd)
Create a `demo_live.exs` file:
```elixir
Mix.install([
{:phoenix_playground, "~> 0.1.6"}
])defmodule DemoLive do
use Phoenix.LiveViewdef mount(_params, _session, socket) do
{:ok, assign(socket, count: 0)}
enddef render(assigns) do
~H"""
<%= @count %>
+
-
body { padding: 1em; }
"""
enddef handle_event("inc", _params, socket) do
{:noreply, assign(socket, count: socket.assigns.count + 1)}
enddef handle_event("dec", _params, socket) do
{:noreply, assign(socket, count: socket.assigns.count - 1)}
end
endPhoenixPlayground.start(live: DemoLive)
```and run it:
```
$ iex demo_live.exs
```
See more examples below:
* [`examples/demo_live.exs`]
* [`examples/demo_live_test.exs`]
* [`examples/demo_controller.exs`]
* [`examples/demo_controller_test.exs`]
* [`examples/demo_plug.exs`]
* [`examples/demo_router.exs`]
* [`examples/demo_hooks.exs`]
* [`examples/demo_endpoint.exs`]
* [`examples/demo_live_pubsub.exs`]## License
Copyright (c) 2024 Wojtek Mach
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.[`examples/demo_live.exs`]: examples/demo_live.exs
[`examples/demo_live_test.exs`]: examples/demo_live_test.exs
[`examples/demo_controller.exs`]: examples/demo_controller.exs
[`examples/demo_controller_test.exs`]: examples/demo_controller_test.exs
[`examples/demo_plug.exs`]: examples/demo_plug.exs
[`examples/demo_router.exs`]: examples/demo_router.exs
[`examples/demo_hooks.exs`]: examples/demo_hooks.exs
[`examples/demo_endpoint.exs`]: examples/demo_endpoint.exs
[`examples/demo_live_pubsub.exs`]: examples/demo_live_pubsub.exs