MadelineProtoDocs/docs/docs/INSTALLATION.md

87 lines
2.0 KiB
Markdown
Raw Normal View History

2018-04-11 14:17:45 +02:00
---
title: Installation
description: There are various ways to install MadelineProto:
image: https://docs.madelineproto.xyz/favicons/android-chrome-256x256.png
---
2018-04-01 13:19:25 +02:00
# Installation
There are various ways to install MadelineProto:
* [Simple](#simple)
* [Simple (manual)](#simple-manual)
* [Composer from scratch](#composer-from-scratch)
* [Composer from existing project](#composer-from-existing-project)
## Simple
```php
<?php
if (!file_exists('madeline.php')) {
2018-08-01 10:08:25 +02:00
copy('https://phar.madelineproto.xyz/madeline.php', 'madeline.php');
2018-04-01 13:19:25 +02:00
}
require_once 'madeline.php';
```
This code will automatically download, auto-update and include MadelineProto.
2019-06-21 17:01:56 +02:00
If you want, you can set a `MADELINE_BRANCH` constant before including `madeline.php`, that will define which branch of MadelineProto madeline.php should load.
When the constant is not set, the latest stable release is loaded.
If the value is an empty string, the `master` branch is loaded.
Otherwise, the selected branch name or tag is loaded.
2019-06-19 18:54:31 +02:00
2018-04-01 13:19:25 +02:00
## Simple (manual)
Download [madeline.php](https://phar.madelineproto.xyz/madeline.php), put it in the same directory as your script, and then put the following code in your PHP file:
```php
<?php
require_once 'madeline.php';
```
## Composer from scratch
composer.json:
2019-12-25 21:22:12 +01:00
```json
2018-04-01 13:19:25 +02:00
{
"name": "yourname/yourproject",
"description": "Project description",
"type": "project",
"require": {
2020-03-01 17:33:06 +01:00
"danog/madelineproto": "^5.1"
2018-04-01 13:19:25 +02:00
},
"license": "AGPL-3.0-only",
"authors": [
{
"name": "Daniil Gentili",
"email": "daniil.gentili.dg@gmail.com"
}
],
"autoload": {
"psr-0": {
"Your\\Project\\": "src/"
}
}
}
```
Then run:
```bash
composer update
```
Put the following code in your PHP file:
```php
<?php
require_once 'vendor/autoload.php';
```
## Composer from existing project
2020-01-19 13:46:19 +01:00
Simply require the package:
2018-04-01 13:19:25 +02:00
2019-12-25 21:22:12 +01:00
```bash
composer require danog/madelineproto
2018-04-01 13:19:25 +02:00
```
2020-03-06 12:24:14 +01:00
<a href="https://docs.madelineproto.xyz/docs/UPDATES.html">Next section</a>