Skip to content
PHP Template for Phoenix Framework
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.formatter.exs
.gitignore
COPYING
README.md
mix.exs
mix.lock

README.md

ephp template

License: LGPL 2.1 Gitter Hex

This is a template system to let you to use PHP templates inside of Phoenix Framework.

Installation

The package can be installed by adding ephp_template to your list of dependencies in mix.exs:

def deps do
  [
    {:ephp_template, "~> 0.1.0"}
  ]
end

In addition to this you can add to the configuration file:

config :phoenix, :template_engines,
    php: Ephp.Template

This way you can create PHP files inside of the template directories and use them in the same way as .html.eex files.

Assigns

Usually from the controllers you can send data to the templates (and views). PHP cannot use the specific functions defined by Phoenix Framework but you can use all of the PHP functions available by default by the ephp project.

The assigns will be included as normal variables inside of PHP. For example, using this controller:

defmodule PhptestWeb.PageController do
  use PhptestWeb, :controller

  def index(conn, _params) do
    render conn, "index.html",
           user: "admin",
           data: [%{"a" => 10, "b" => 20}, %{"a" => 11, "b" => 21}]
  end
end

You'll have access to $user and $data variables in the template. You can create the file index.html.php and then do whatever you need.

Superglobals

Maybe it's not needed but you have populated $_SERVER (not completely), $_REQUEST (and $_GET and $_POST as well), $_ENV and $_COOKIE.

Donation

If you want to support the project to advance faster with the development you can make a donation. Thanks!

paypal

Enjoy!

You can’t perform that action at this time.