diff --git a/.phpcs.xml b/.phpcs.xml
index 7b6fa93b6..fcb99ca4b 100644
--- a/.phpcs.xml
+++ b/.phpcs.xml
@@ -7,7 +7,6 @@
- brefsrctests
diff --git a/bref b/bref
deleted file mode 100755
index 75a438b55..000000000
--- a/bref
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/usr/bin/env php
- 'vendor/bin/bref',
- 'v' => 2, // Bref version
- 'c' => $argv[1] ?? '',
- 'ci' => $ci,
- // anonymous user ID created by the Serverless Framework
- 'uid' => $userConfig['frameworkId'] ?? '',
- ], JSON_THROW_ON_ERROR);
-
- $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
- // This IP address is the Bref server.
- // If this server is down or unreachable, there should be no difference in overhead
- // or execution time.
- socket_sendto($sock, $message, strlen($message), 0, '108.128.197.71', 8888);
- socket_close($sock);
-}
diff --git a/composer.json b/composer.json
index f8d7d7cac..f16297025 100644
--- a/composer.json
+++ b/composer.json
@@ -16,7 +16,6 @@
}
},
"bin": [
- "bref",
"src/bref-local"
],
"require": {
diff --git a/docs/default/getting-started.mdx b/docs/default/getting-started.mdx
index bf2cbd87e..796f1ea8e 100644
--- a/docs/default/getting-started.mdx
+++ b/docs/default/getting-started.mdx
@@ -27,33 +27,29 @@ Next, in an empty directory, install Bref using Composer:
composer require bref/bref
```
-Make sure that the version of Bref that was installed is 1.0 or greater.
+Make sure that the version of Bref that was installed is 3.0 or greater.
-Then let's start by initializing a new project by running:
+Then, create a `serverless.yml` file. This file will describe how to deploy your application.
-```bash
-vendor/bin/bref init
-```
-
-Accept all the defaults by pressing "Enter". The following files will be created in your project:
-
-- `index.php` contains the code of your application
-- `serverless.yml` contains the configuration for deploying on AWS
-
-You are free to edit `index.php`.
+```yml filename="serverless.yml"
+service: app # your application name (lowercase without spaces)
-To deploy an existing application, you can delete `index.php` and edit `serverless.yml` to point to your existing index file (for example it may be another file like `public/index.php`). You can also create the `serverless.yml` file manually:
+bref:
+ # Uncomment and set your team ID if you are using Bref Cloud
+ #team: bref-team-id
-```yml filename="serverless.yml"
-service: app
provider:
name: aws
- region: us-east-1
+ region: us-east-1 # AWS region to deploy to
+ environment: # Environment variables
+ APP_ENV: prod
functions:
web:
+ # `index.php` is the entrypoint of your application
handler: index.php
runtime: php-84-fpm
+ timeout: 28 # in seconds (API Gateway has a max timeout of 29 seconds)
events:
- httpApi: '*'
@@ -66,6 +62,21 @@ plugins:
- ./vendor/bref/bref
```
+If your `index.php` entrypoint is in a different folder, feel free to adjust the `handler` key. For example if it is in `public/index.php`:
+
+```yml
+ handler: public/index.php
+```
+
+If this is a new application, you can create a very simple `index.php` file to test things out, for example:
+
+```php
+find('serverless')) {
- warning(
- 'The `serverless` command is not installed.' . PHP_EOL .
- 'You will not be able to deploy your application unless it is installed' . PHP_EOL .
- 'Please follow the instructions at https://bref.sh/docs/installation.html' . PHP_EOL .
- 'If you have the `serverless` command available elsewhere (eg in a Docker container) you can ignore this warning.' . PHP_EOL
- );
- }
-
- if (! $template) {
- $intro = green('What kind of application are you building?');
- echo << ') ?: '0';
- echo PHP_EOL;
- if (! in_array($choice, ['0', '1', '2'], true)) {
- error('Invalid response (must be "0", "1" or "2"), aborting');
- }
-
- $template = [
- '0' => 'http',
- '1' => 'function',
- '2' => 'symfony',
- ][$choice];
- }
-
- $rootPath = dirname(__DIR__, 2) . "/template/$template";
-
- if (file_exists($rootPath . '/index.php')) {
- createFile($rootPath, 'index.php');
- }
- createFile($rootPath, 'serverless.yml');
-
- // If these is a `.gitignore` file in the current directory, let's add `.serverless` to it
- if (file_exists('.gitignore')) {
- $gitignore = file_get_contents('.gitignore');
- if (! str_contains($gitignore, '.serverless')) {
- file_put_contents('.gitignore', PHP_EOL . '.serverless' . PHP_EOL, FILE_APPEND);
- success('Added `.serverless` to your `.gitignore` file.');
- }
- }
-
- success('Project initialized and ready to test or deploy.');
-}
-
-/**
- * Creates files from the template directory and automatically adds them to git
- */
-function createFile(string $templatePath, string $file): void
-{
- echo "Creating $file\n";
-
- if (file_exists($file)) {
- $overwrite = false;
- echo "A file named $file already exists, do you want to overwrite it? [y/N]\n";
- $choice = strtolower(readline('> ') ?: 'n');
- echo PHP_EOL;
- if ($choice === 'y') {
- $overwrite = true;
- } elseif (! in_array($choice, ['y', 'n'], true)) {
- error('Invalid response (must be "y" or "n"), aborting');
- }
- if (! $overwrite) {
- echo "Skipping $file\n";
- return;
- }
- }
-
- $template = file_get_contents("$templatePath/$file");
- if (! $template) {
- error("Could not read file $templatePath/$file");
- }
- $template = str_replace('PHP_VERSION', PHP_MAJOR_VERSION . PHP_MINOR_VERSION, $template);
- file_put_contents($file, $template);
-
- /*
- * We check if this is a git repository to automatically add file to git.
- */
- $message = "$file successfully created";
- if ((new Process(['git', 'rev-parse', '--is-inside-work-tree']))->run() === 0) {
- (new Process(['git', 'add', $file]))->run();
- $message .= ' and added to git automatically';
- }
-
- echo PHP_EOL;
- success("$message.");
-}
diff --git a/template/function/index.php b/template/function/index.php
deleted file mode 100644
index 346496cb7..000000000
--- a/template/function/index.php
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
- Welcome!
-
-
-
-
-
-
Hello there,
-
-
-
-
-
-
-
diff --git a/template/http/serverless.yml b/template/http/serverless.yml
deleted file mode 100644
index 65f86f77e..000000000
--- a/template/http/serverless.yml
+++ /dev/null
@@ -1,27 +0,0 @@
-service: app
-
-# Set your team ID if you are using Bref Cloud
-#bref:
-# team: my-team-id
-
-provider:
- name: aws
- region: us-east-1
-
-plugins:
- - ./vendor/bref/bref
-
-functions:
- api:
- handler: index.php
- description: ''
- runtime: php-PHP_VERSION-fpm
- timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
- events:
- - httpApi: '*'
-
-# Exclude files from deployment
-package:
- patterns:
- - '!node_modules/**'
- - '!tests/**'
diff --git a/template/symfony/serverless.yml b/template/symfony/serverless.yml
deleted file mode 100644
index 48c49adb6..000000000
--- a/template/symfony/serverless.yml
+++ /dev/null
@@ -1,47 +0,0 @@
-# Read the documentation at https://bref.sh/docs/symfony/getting-started
-service: symfony
-
-# Set your team ID if you are using Bref Cloud
-#bref:
-# team: my-team-id
-
-provider:
- name: aws
- # The AWS region in which to deploy (us-east-1 is the default)
- region: us-east-1
- environment:
- # Symfony environment variables
- APP_ENV: prod
-
-plugins:
- - ./vendor/bref/bref
-
-functions:
-
- # This function runs the Symfony website/API
- web:
- handler: public/index.php
- runtime: php-82-fpm
- timeout: 28 # in seconds (API Gateway has a timeout of 29 seconds)
- events:
- - httpApi: '*'
-
- # This function let us run console commands in Lambda
- console:
- handler: bin/console
- runtime: php-82-console
- timeout: 120 # in seconds
-
-package:
- patterns:
- # Excluded files and folders for deployment
- - '!assets/**'
- - '!node_modules/**'
- - '!public/build/**'
- - '!tests/**'
- - '!var/**'
- # If you want to include files and folders that are part of excluded folders,
- # add them at the end
- - 'var/cache/prod/**'
- - 'public/build/entrypoints.json'
- - 'public/build/manifest.json'
diff --git a/tests/CliTest.php b/tests/CliTest.php
deleted file mode 100644
index 09b03afc0..000000000
--- a/tests/CliTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-mustRun();
- self::assertNotEmpty($process->getOutput());
- }
-}