Download the PHP package mpphp/view without Composer

On this page you can find all versions of the php package mpphp/view. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package view

Veiw

MPPHP view library.

A view is the file that contains the code that gets printed on the browser period. And the MVC architecture demands that we keep our business logic away from these view files. Traditionally beginners i thought to make database calls or process their forms on the same file as the form:


<form method="post">
    // Required inputs

    <input type="submit" name="submit" value="Sign in">
</form>

This would be a bad idea because now your View now has knowledge of your backend code. Now most people at this point would say theu write their logic in a different file and include it like so:


<form method="post">
    // Required inputs

    <input type="submit" name="submit" value="Sign in">
</form>

Well technically, the two versions are the same, the view is still aware of the back end logic.

There are lots of third party Templating Engines out there like Smarty, Latte, Mustache, but most PHP frameworks come bundled with their own Templating engine, for example Symfony has Twig, Laravel has Blade and Phalcon has Volt. And MpPHP well, it just has a single file containing functions that mimic the important features of a Templating Engine like Inheritance and Sections/Blocks that we like to call VIEW.

Defining A Layout

Two of the primary benefits of using a templating engine are template inheritance and sections. To get started, let's take a look at a simple example. First, we will examine a "master" page layout. Since most web applications maintain the same general layout across various pages, it's convenient to define this layout as a single Blade view:

As you can see, this file contains typical HTML mark-up. However, take note of the _viewnest() and the _view__include() functions. The _viewinclude function, as the name implies, includes a template, while the _view__nest() function is used to display the contents of a given section.

Now that we have defined a layout for our application, let's define a child page that inherits the layout.

Extending A Layout

When defining a child vtemplate, use the _viewextends() function to specify which layout the child template should "inherit". Templates which extend a layout may inject content into the parent template by wrapping its content in a function with the same name passed into it's parents _view__nest() function. Remember, as seen in the example above, the contents of these sections will be displayed in the layout _viewnest('content'):

<!-- Stored in resources/views/child.phtml -->

    Child Page

    <p>This is my body content.</p>

From this section down, we would be talking about best practices for using PHP in a view or a template file.

Displaying Data

To display a PHP value to the browser, we would use echo or print but if the only thing your doing withing a PHP opening an closing tag is an echo or print you can use the shorthand version like so:

<?= $data ?>

Much simpler than:

 or 

Dont you think?

Control Structures

It is common for young developers to mix their view with business logic in a way that makes it impossible for a front end developer who has little knowledge of PHP to work with their projects, for example it is comon to find a view that has the following code:

<body>

</body>

If your working on a school project with your friends and your job is at the back end of things, i guess we can all agree the above could be alot for the person handling the front. A cleaner way to get this do would be to drop out of PHP as soon as we don't need it:

<body>

        <div>
            <p> 
                <?= $info ?>
            </p>
        </div>

</body>

This would be easier for any front end personel to work on your project without having to worry about PHP, I mean it's there but they can easily be ignored compared to the previous version.

This step would work for both Control structures and logical expressions likewise.


All versions of view with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
mpphp/support Version ~v1.0.0-alpha
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mpphp/view contains the following files

Loading the files please wait ....