All Projects β†’ juicyfx β†’ Vercel Php

juicyfx / Vercel Php

Licence: mit
β–² Vercel PHP runtime β€’ vercel-php β€’ now-php β€’ 🐘+ Ξ» = ❀

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Vercel Php

Jwt Example
Playing with user registration, login/logout, auth, etc using JWTs, serverless functions & faunadb as the data store.
Stars: ✭ 22 (-94.87%)
Mutual labels:  lambda, now, zeit
Aws Security Workshops
A collection of the latest AWS Security workshops
Stars: ✭ 332 (-22.61%)
Mutual labels:  aws, lambda
Bash Lambda Layer
Run Bash scripts in AWS Lambda via Layers
Stars: ✭ 390 (-9.09%)
Mutual labels:  aws, lambda
Cloud Custodian
Rules engine for cloud security, cost optimization, and governance, DSL in yaml for policies to query, filter, and take actions on resources
Stars: ✭ 3,926 (+815.15%)
Mutual labels:  aws, lambda
Grant
OAuth Proxy
Stars: ✭ 3,509 (+717.95%)
Mutual labels:  aws, lambda
Aws Serverless Workshops
Code and walkthrough labs to set up serverless applications for Wild Rydes workshops
Stars: ✭ 3,512 (+718.65%)
Mutual labels:  aws, lambda
Meteor Now
Instantly deploy your Meteor apps with `meteor-now`
Stars: ✭ 339 (-20.98%)
Mutual labels:  now, zeit
Covid19 Brazil Api
API com dados atualizados sobre o status do COVID-19 🦠
Stars: ✭ 300 (-30.07%)
Mutual labels:  now, zeit
Micro Proxy
[DEPRECATED] Simplest proxy server for microservices
Stars: ✭ 358 (-16.55%)
Mutual labels:  now, zeit
Aws Serverless Workshop Innovator Island
Welcome to the Innovator Island serverless workshop! This repo contains all the instructions and code you need to complete the workshop. Questions? Contact @jbesw.
Stars: ✭ 363 (-15.38%)
Mutual labels:  aws, lambda
Aws Microservices Deploy Options
This repo contains a simple application that consists of three microservices. Each application is deployed using different Compute options on AWS.
Stars: ✭ 370 (-13.75%)
Mutual labels:  aws, lambda
Serverless Iam Roles Per Function
Serverless Plugin for easily defining IAM roles per function via the use of iamRoleStatements at the function level.
Stars: ✭ 311 (-27.51%)
Mutual labels:  aws, lambda
Aws Lambda Cpp
C++ implementation of the AWS Lambda runtime
Stars: ✭ 300 (-30.07%)
Mutual labels:  aws, lambda
Auto Tag
Automatically tag AWS resources on creation, for cost assignment
Stars: ✭ 322 (-24.94%)
Mutual labels:  aws, lambda
Lambdaguard
AWS Serverless Security
Stars: ✭ 300 (-30.07%)
Mutual labels:  aws, lambda
Terraform Aws Github Runner
Terraform module for scalable GitHub action runners on AWS
Stars: ✭ 326 (-24.01%)
Mutual labels:  aws, lambda
Up Examples
Example apps, apis, and sites for Up.
Stars: ✭ 381 (-11.19%)
Mutual labels:  aws, lambda
Serverless Bundle
Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
Stars: ✭ 295 (-31.24%)
Mutual labels:  aws, lambda
Realtime App
Deploy a serverless realtime app built on AWS Lambda using Serverless Components.
Stars: ✭ 299 (-30.3%)
Mutual labels:  aws, lambda
Nodb
NoDB isn't a database.. but it sort of looks like one.
Stars: ✭ 353 (-17.72%)
Mutual labels:  aws, lambda

PHP Runtime for Vercel

Enjoyable & powerful 🐘 PHP Runtime (php.vercel.app) for Vercel platform.

πŸ‹οΈβ€β™€οΈ It works with these frameworks and tools. Discover more at examples.

Made with ❀️ by @f3l1x (f3l1x.io) β€’ 🐦 @xf3l1x


😎 Getting Started

Let's picture you want to deploy your awesome microproject written in PHP and you don't know where. You have found Vercel it's awesome, but for static sites. Not anymore! I would like to introduce you your new best friend vercel-php, PHP runtime for Vercel platform.

Most simple example project is this one, using following project structure.

project
β”œβ”€β”€ api
β”‚   └── index.php
└── vercel.json

First file api/index.php is entrypoint of our application. It should be placed in api folder, it's very standard location for Vercel.

<?php
phpinfo();

Second file vercel.json is pure gold here. Setup your project with configuration like this and voila. That's all.

{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]"
    }
  }
}

Last thing you have to do is call vercel. If you are more interested take a look at features and usage.

# Install it globally
npm i -g vercel

# Log in
vercel login

# Let's fly
vercel

Are you ready to deploy your first PHP project to Vercel? Click & Go!

πŸ€— Features

  • Architecture: PHP development server (πŸš€ fast enough)
  • PHP version: 8.0.0
  • Extensions: apcu, bcmath, brotli, bz2, calendar, Core, ctype, curl, date, dom, ds, exif, fileinfo, filter, ftp, gettext, hash, iconv, igbinary, imap, intl, json, libxml, lua, mbstring, mongodb, msgpack, mysqli, mysqlnd, openssl, pcntl, pcre, PDO, pdo_mysql, pdo_pgsql, pdo_sqlite, pgsql, phalcon, Phar, protobuf, psr, readline, redis, Reflection, runkit7, session, SimpleXML, soap, sockets, sodium, SPL, sqlite3, standard, swoole, timecop, tokenizer, uuid, xml, xmlreader, xmlrpc, xmlwriter, xsl, Zend OPcache, zlib
  • Speed: cold ~250ms / warm ~5ms
  • Memory: ~90mb
  • Frameworks: Nette, Symfony, Lumen, Slim, Phalcon

List of all installable extensions is on this page https://blog.remirepo.net/pages/PECL-extensions-RPM-status.

βš™οΈ Usage

Before you can start using this runtime, you should learn about Vercel and how runtimes works. Take a look at blogpost about Serverless Functions.

You should define functions property in vercel.json and list PHP files directly or using wildcard (*). If you need to route everything to index, use routes property.

{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]"
    }
  },
  "routes": [
    { "src": "/(.*)",  "dest": "/api/index.php" }
  ]
}

Do you have more questions (❓)? Let's move to FAQ.

πŸ‘¨β€πŸ’» vercel dev

For running vercel dev properly, you need to have PHP installed on your computer, learn more. But it's PHP and as you know PHP has built-in development server. It works out of box.

php -S localhost:8000 api/index.php

πŸ‘€ Demo

PHP

🎯Examples

Browse more examples. πŸ‘€

πŸ“œ Resources

🚧 Roadmap

Next

Done

  • next-gen PHP runtime
  • Composer
    • config.composer: true
    • composer.json detection
  • zero config
  • customize php.ini
  • vercel dev
  • typescript codebase
  • github workflows (CI)
  • PHP 7.4
  • composer.json scripts
  • PHP 8.0

Help wanted

  • create examples using vercel-php

⁉️ FAQ

1. How to use more then one endpoint (index.php)?
project
β”œβ”€β”€ api
β”‚   β”œβ”€β”€ index.php
β”‚   β”œβ”€β”€ users.php
β”‚   └── books.php
└── vercel.json
{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]"
    },

    // Can be list also directly

    "api/index.php": {
      "runtime": "[email protected]"
    },
    "api/users.php": {
      "runtime": "[email protected]"
    },
    "api/books.php": {
      "runtime": "[email protected]"
    }
  }
}
2. How to route everything to index?
{
  "functions": {
    "api/index.php": {
      "runtime": "[email protected]"
    }
  },
  "routes": [
    { "src": "/(.*)",  "dest": "/api/index.php" }
  ]
}
3. How to update memory limit?

Additional function properties are memory, maxDuration. Learn more about functions.

{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]",
      "memory": 3008,
      "maxDuration": 60
    }
  }
}
4. How to use it with Composer?

Yes, Composer is fully supported.

project
β”œβ”€β”€ api
β”‚   └── index.php
β”œβ”€β”€ composer.json
└── vercel.json
{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]"
    }
  }
}
{
  "require": {
    "php": "^7.4",
    "tracy/tracy": "^2.0"
  }
}

It's also good thing to create .vercelignore file and put /vendor folder to this file. It will not upload /vendor folder to Vercel platform.

5. How to override php.ini / php configuration ?

Yes, you can override php configuration. Take a look at default configuration at first. Create a new file api/php.ini and place there your configuration. Don't worry, this particulary file will be removed during building phase on Vercel.

project
β”œβ”€β”€ api
β”‚   β”œβ”€β”€ index.php
β”‚   └── php.ini
└── vercel.json
{
  "functions": {
    "api/*.php": {
      "runtime": "[email protected]"
    }
  }
}
# Disable some functions
disable_functions = "exec, system"

# Update memory limit
memory_limit=1024M
6. How to exclude some files or folders ?

Runtimes support excluding some files or folders, take a look at doc.

{
  "functions": {
  "api/**/*.php": {
    "runtime": "[email protected]",
    "excludeFiles": "{foo/**,bar/config/*.yaml}",
  }
}

If you want to exclude files before uploading them to Vercel, use .vercelignore file.

7. How to call composer script(s) ?

Calling composer scripts during build phase on Vercel is supported via script named vercel. You can easilly call php, npm or node.

{
  "require": { ... },
  "require-dev": { ... },
  "scripts": {
    "vercel": [
      "@php -v",
      "npm -v"
    ]
  }
}

Files created during composer run vercel script can be used (require/include) in your PHP lambdas, but can't be accessed from browser (like assets). If you still want to access them, create fake assets.php lambda and require them. Example of PHP satis.

8. How to include some files of folders?

If you are looking for config.includeFiles in runtime, unfortunately you can't include extra files. All files in root folder are uploaded to Vercel, use .vercelignore to exclude them before upload.

9. How to develop locally?

I think the best way at this moment is use PHP Development Server.

php -S localhost:8000 api/index.php

πŸ‘¨πŸ»β€πŸ’»CHANGELOG

Show me CHANGELOG

πŸ§™Contribution

  1. Clone this repository.
  2. Install NPM dependencies
    • make install
  3. Make your changes
  4. Run TypeScript compiler
    • make build
  5. Run tests
    • make test
  6. Create a PR

πŸ“ License

Copyright Β© 2019 f3l1x. This project is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].