Giter VIP home page Giter VIP logo

heroku-php-sqlsrv-buildpack's Introduction

Steps to be followed for installing Microsoft ODBC Driver v17, v18 For PHP For Sql Server on Ubuntu 20.04

How to use these Modules

The code samples are available here

SQLSRV and PDO_SQLSRV drivers

  • v5.9.0 supports PHP ^7.4.0 to ~8.0.0
  • v5.10.0 supports PHP ^7.4.0 to ~8.1.0

Add Aptfile File

Aptfile file is mandatory, create a file called Aptfile in your project root folder and

to your project root folder.

Add Environment Variable For Extension Repositories

It must be set,

PHP 8.1

heroku config:set HEROKU_PHP_PLATFORM_REPOSITORIES="https://github.com/heroku-softtrends/mssql-server-drivers-for-php/raw/main/5.10.0/ubuntu/20.04/php/8.1/nts/packages.json" -a <heroku_app_name>

PHP 8.0

heroku config:set HEROKU_PHP_PLATFORM_REPOSITORIES="https://github.com/heroku-softtrends/mssql-server-drivers-for-php/raw/main/5.9.0/ubuntu/20.04/php/8.0/nts/packages.json" -a <heroku_app_name>

PHP 7.4

heroku config:set HEROKU_PHP_PLATFORM_REPOSITORIES="https://github.com/heroku-softtrends/mssql-server-drivers-for-php/raw/main/5.9.0/ubuntu/20.04/php/7.4/nts/packages.json" -a <heroku_app_name>

Update your composer.json file

Add required dependencies to composer.json file

PHP 8.1

{
    "require": {
      "php": "~8.1.0",
      "ext-sqlsrv": "^5.10",
      "ext-pdo_sqlsrv": "^5.10"
    }
}

PHP 8.0

{
    "require": {
      "php": "~8.0.0",
      "ext-sqlsrv": "^5.9",
      "ext-pdo_sqlsrv": "^5.9"
    }
}

PHP 7.4

{
    "require": {
      "php": "~7.4.0",
      "ext-sqlsrv": "^5.9",
      "ext-pdo_sqlsrv": "^5.9"
    }
}

After adding new dependencies to composer.json file, must be updated by running:

$ composer update --ignore-platform-reqs

Finally the composer.lock file will look like,

PHP 8.1

{
  "platform": {
    "php": "~8.1.0",
    "ext-pdo_sqlsrv": "^5.10",
    "ext-sqlsrv": "^5.10"
   }
}

PHP 8.0

{
  "platform": {
    "php": "~8.0.0",
    "ext-sqlsrv": "^5.9",
    "ext-pdo_sqlsrv": "^5.9"
  }
}

PHP 7.4

{
  "platform": {
    "php": "~7.4.0",
    "ext-sqlsrv": "^5.9",
    "ext-pdo_sqlsrv": "^5.9"
  }
}

Add Buildpacks

  • The first buildpak: https://github.com/heroku/heroku-buildpack-apt.git
  • The second buildpack: https://github.com/heroku/heroku-buildpack-php.git
  • The last buildpack: https://github.com/heroku-softtrends/heroku-php-sqlsrv-buildpack.git

Now deploy

$ git init
$ heroku git:remote -a <app_name>
$ git add --all
$ git commit -m "First commit"
$ git push heroku master

Finally, check that everything is working

$ heroku open -a <heroku_app_name>

References

Getting started with php

Heroku platform dependencies installation

Heroku php buildpack

heroku-php-sqlsrv-buildpack's People

Contributors

heroku-softtrends avatar shanmugam-softtrends avatar

Watchers

 avatar  avatar  avatar

Forkers

vitisstudio

heroku-php-sqlsrv-buildpack's Issues

Heroku Pushes fail when referencing this package

When trying to push to Heroku, if fails. According to Heroku support the problem lies within this package.

Part of the error message is posted below:

     Problem 1
       - Root composer.json requires PHP extension ext-sqlsrv ^5.10 but it is missing from your system. Install or enable PHP's sqlsrv extension.
     Problem 2
       - Root composer.json requires PHP extension ext-pdo_sqlsrv ^5.10 but it is missing from your system. Install or enable PHP's pdo_sqlsrv extension.
   
   To enable extensions, verify that they are enabled in your .ini files:
       - /app/.heroku/php/etc/php/php.ini
       - /app/.heroku/php/etc/php/conf.d/000-heroku.ini
       - /app/.heroku/php/etc/php/conf.d/010-ext-zend_opcache.ini
       - /app/.heroku/php/etc/php/conf.d/100-ext-sqlsrv.ini
       - /app/.heroku/php/etc/php/conf.d/110-ext-soap.ini
       - /app/.heroku/php/etc/php/conf.d/120-ext-pdo_sqlsrv.ini
       - /tmp/codon/tmp/buildpacks/924b28589fd8017df2c94cc0b5722165fa7a91ef/conf/php/apm-nostart-overrides/apm-nostart-overrides.ini
   You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
   Alternatively, you can run Composer with `--ignore-platform-req=ext-sqlsrv --ignore-platform-req=ext-pdo_sqlsrv` to temporarily ignore these required extensions.

[1;31m
! ERROR: Dependency installation failed!
!
! The 'composer install' process failed with an error. The cause
! may be the download or installation of packages, or a pre- or
! post-install hook (e.g. a 'post-install-cmd' item in 'scripts')
! in your 'composer.json'.
!
! Typical error cases are out-of-date or missing parts of code,
! timeouts when making external connections, or memory limits.
!
! Check the above error output closely to determine the cause of
! the problem, ensure the code you're pushing is functioning
! properly, and that all local changes are committed correctly.
!
! For more information on builds for PHP on Heroku, refer to
! https://devcenter.heroku.com/articles/php-support
[0m
! Push rejected, failed to compile PHP app.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.