{"id":19838949,"url":"https://github.com/cabdesigns/alexa-next-bus-php","last_synced_at":"2025-11-22T19:04:33.655Z","repository":{"id":82061260,"uuid":"95493535","full_name":"cabdesigns/alexa-next-bus-php","owner":"cabdesigns","description":"Alexa skill to retrieve the next bus, using PHP on AWS Lambda","archived":false,"fork":false,"pushed_at":"2017-07-08T12:22:49.000Z","size":8408,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-11T11:19:28.128Z","etag":null,"topics":["aws-lambda","nodejs","php","serverless","serverless-framework","transport-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cabdesigns.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-26T22:07:10.000Z","updated_at":"2017-07-08T12:23:47.000Z","dependencies_parsed_at":"2023-11-01T15:15:12.978Z","dependency_job_id":null,"html_url":"https://github.com/cabdesigns/alexa-next-bus-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabdesigns%2Falexa-next-bus-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabdesigns%2Falexa-next-bus-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabdesigns%2Falexa-next-bus-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cabdesigns%2Falexa-next-bus-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cabdesigns","download_url":"https://codeload.github.com/cabdesigns/alexa-next-bus-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241209528,"owners_count":19927734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws-lambda","nodejs","php","serverless","serverless-framework","transport-api"],"created_at":"2024-11-12T12:19:41.179Z","updated_at":"2025-11-22T19:04:33.624Z","avatar_url":"https://github.com/cabdesigns.png","language":"PHP","readme":"# Alexa Next Bus PHP\n\nThis project is an example serverless function that can be used to power a PHP based Alexa Skill, running on AWS Lambda, to fetch the next bus times from a number of configured bus stops (using the [TransportAPI](https://transportapi.com)). \n\n# Steps\n\n### Prerequisites for development\n- [node.js v6.10](https://nodejs.org)\n- [php 7.1](https://secure.php.net/)\n- [TransportAPI account](https://developer.transportapi.com/)\n\n### Install serverless\n\n`npm install serverless -g`\n\n### Install dependencies\n\n`docker run --rm -v $(pwd):/app composer/composer install`\n\n### Run locally\n\n`sls invoke local --function nextBus`\n\nNOTE: You will need php 7 installed locally. Not ideal, but necessary without avoiding this and using docker for local testing instead.\n\n### Setup AWS creds\n\n`serverless config credentials --provider aws --key AKIAIOSFODNN7EXAMPLE --secret wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`\n\nSee https://git.io/vXsdd\n\n### Deploy\n\n`sls deploy`\n\n### Add trigger\n\nChoose alexa skills kit.\n\n### Create Alexa skill\n\nCreate a new skill, applying the invocation name \"bus timetables\". Insert ARN of AWS Lambda we just created. Intent not necessary at this stage, as this basic skill only does one thing, and happens on the launch request.\n\n## Test!\n\n\"Alexa, open bus timetables.\"\n\n## Rebuilding the PHP binary\n\nIf you need different compiler flags or dependencies you will need to recompile PHP.\n\n### Prerequisites\n- [docker](https://www.docker.com/)\n\n### Compile the static standalone PHP 7 binary\nTo do this, we have to compile the PHP 7.1.2 with statically linked libraries:\n\n```shell\nsh buildphp.sh\n```\n\n### PHP Version\nThe default is to use the PHP 7.1.2 branch to compile the PHP binary.\nTo switch the PHP version you can set the branch PHP_VERSION_GIT_BRANCH parameter in `buildphp.sh` line 8.\n\n# FAQs\n\n### How do I get the ATCO code for my bus stop(s)?\n\nOne of the easiest ways is to find your bus stop on [OpenStreetMap](https://www.openstreetmap.org/node/496714689). Clicking on the stop should reveal data including the all important `naptan:AtcoCode`. This is the value you want to use.\n \nFrom experience (examining bus stops by First Leeds), this tends to just look like the SMS code but with an extra 0. You might be able to guess the ATCO code if data is not readily available on OpenStreetMap.\n\nAlternatively, you can view the full data set from DfT [here](https://data.gov.uk/dataset/naptan).\n\n# Thanks\nHuge thanks to [Robert Anderson](https://twitter.com/8ctopus) for piecing together the [serverless framework template](https://github.com/ZeroSharp/serverless-php) that this PoC is based on.\n\n# Further reading\n### Serverless PHP\n- https://serverless.com/\n- http://blog.zerosharp.com/the-serverless-framework-and-php/\n- http://blog.gaiterjones.com/amazon-alexa-php-hello-world-example/\n- https://github.com/nomisoft/PHP-Alexa-Helper\n- https://github.com/awspilot/aws-lambda-php-template\n- https://github.com/dannylinden/aws-lambda-php\n- https://github.com/ZeroSharp/serverless-php\n\n### Async PHP\n- [Asynchronous API Interaction with Guzzle Session @ZendCon 2015](https://www.youtube.com/watch?v=4J7p0CZ0aQ4)\n- [Steve Maraspin - Meet a parallel, asynchronous PHP world](https://www.youtube.com/watch?v=dk-D3g2MD2U) \n- [The promise of asynchronous PHP - Wim Godden](https://www.youtube.com/watch?v=JCE6G_b1-eA\u0026t=466s)\n- https://blog.madewithlove.be/post/concurrent-http-requests/\n- https://blog.newrelic.com/2016/03/14/guzzle/\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcabdesigns%2Falexa-next-bus-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcabdesigns%2Falexa-next-bus-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcabdesigns%2Falexa-next-bus-php/lists"}