Skip to content
Open

dev #391

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ BOUNCE_IMAP_PURGE_UNPROCESSED=0
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=true
SEARCH_TRANSPORT_DSN=doctrine://default?queue_name=search_index

# Scheduler (run `bin/console messenger:consume scheduler_default`, see docs/Scheduling.md).
# Relative intervals; set to an empty value to disable an entry.
PHPLIST_SCHEDULE_QUEUE="1 minute"
PHPLIST_SCHEDULE_BOUNCES="1 day"
PHPLIST_SCHEDULE_TLDS="1 month"
PHPLIST_SCHEDULE_CLEANUP="1 day"

# Elasticsearch configuration
# Set to false to fall back to reading/writing these tables straight from MySQL - no Elasticsearch
# cluster required. See docs/ElasticsearchSearch.md.
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ jobs:
- name: Install Symfony CLI
run: |
curl -sS https://get.symfony.com/cli/installer | bash
mv $HOME/.symfony*/bin/symfony /usr/local/bin/symfony
echo "$HOME/.config/symfony-cli/bin" >> "$GITHUB_PATH"
export PATH="$HOME/.config/symfony-cli/bin:$PATH"
symfony version
- name: Start mysql service
run: sudo /etc/init.d/mysql start
Expand All @@ -65,6 +66,8 @@ jobs:
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
- name: Check Symfony requirements
run: vendor/bin/requirements-checker
- name: Validating composer.json
run: composer validate --no-check-all --no-check-lock --strict;
- name: Linting all php files
Expand Down
70 changes: 70 additions & 0 deletions .github/workflows/migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Database migrations
# Checks that the migrations in src/Migrations build, on an empty database, a schema that matches the Doctrine
# mapping. Separate from ci.yml because ci.yml loads resources/Database/Schema.sql (the legacy schema) and only
# validates the mapping with --skip-sync; this job tests the migrations themselves.
on: [push, pull_request]
jobs:
migrations:
name: Migrations build a schema matching the Doctrine mapping
runs-on: ubuntu-22.04
env:
DB_DATABASE: phplist_migrations
DB_USERNAME: root
DB_PASSWORD: phplist
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: ${{ env.DB_PASSWORD }}
# created empty by the service; only this job uses it
MYSQL_DATABASE: ${{ env.DB_DATABASE }}
ports:
- 3306/tcp
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: mbstring, dom, fileinfo, mysql
coverage: none
- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --prefer-dist --no-progress
- name: Point the application at the migrations database
run: |
{
echo "PHPLIST_DATABASE_NAME=${{ env.DB_DATABASE }}"
echo "PHPLIST_DATABASE_USER=${{ env.DB_USERNAME }}"
echo "PHPLIST_DATABASE_PASSWORD=${{ env.DB_PASSWORD }}"
echo "PHPLIST_DATABASE_HOST=127.0.0.1"
echo "PHPLIST_DATABASE_PORT=${{ job.services.mysql.ports['3306'] }}"
} >> "$GITHUB_ENV"
- name: Run the migrations
run: php bin/console doctrine:migrations:migrate --no-interaction
- name: Check the init migration created every table of its dump
run: |
tables=$(mysql --host 127.0.0.1 --port "$PHPLIST_DATABASE_PORT" -u"$PHPLIST_DATABASE_USER" -p"$PHPLIST_DATABASE_PASSWORD" -N \
-e "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '$PHPLIST_DATABASE_NAME' AND table_name LIKE 'phplist\_%'")
expected=$(grep -c '^CREATE TABLE' src/Migrations/initial_schema.sql)
echo "phpList tables created by the migrations: $tables (the init dump alone creates $expected)"
if [ "$tables" -lt "$expected" ]; then
echo "::error::The migrations created only $tables of the $expected tables in the init dump."
exit 1
fi
- name: Create the Messenger transport tables
# messenger_messages is created by Messenger's auto_setup on first use, not by a migration, but it is
# part of the schema that doctrine:schema:validate expects.
run: php bin/console messenger:setup-transports
- name: Validate the schema against the Doctrine mapping
run: php bin/console doctrine:schema:validate
167 changes: 11 additions & 156 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ This module should not be modified locally. It should be updated via Composer.

## Requirements

* PHP 8.1 or higher
* Symfony 6.4 components
* PHP 8.2 or higher
* Symfony 7.4 components
* Doctrine ORM 3.3

## Installation
Expand All @@ -52,167 +52,22 @@ this code.

## Documentation

Architecture and domain:
* [Class structure overview](docs/ClassStructure.md)
* [Domain model diagram](docs/DomainModel/DomainModel.svg) and [description of the domain entities](docs/DomainModel/Entities.md)

Features and configuration:
* [Mailer transports](docs/MailerTransports.md) - configuring Gmail, Amazon SES, Mailchimp, and SendGrid
* [Asynchronous email sending](docs/AsyncEmailSending.md) - queuing email delivery with Symfony Messenger
* [Scheduling](docs/Scheduling.md) - running recurring tasks with the Symfony Scheduler or crontab
* [Graylog integration](docs/Graylog.md) - centralized log management
* [Elasticsearch-backed search for big tables](docs/ElasticsearchSearch.md) - dual-write to the database and Elasticsearch, reading from Elasticsearch only
* [Generating class API docs](PHPDOC.md) - regenerating the phpDocumentor output

## Running the web server

The phpList application is configured so that the built-in PHP web server can
run in development and testing mode, while Apache can run in production mode.

Please first set the database credentials in `.env` (created from `.env.dist` on `composer install`/`composer update`).

### Development

To run the application in development mode using PHP's built-in server,
use this command:

```bash
bin/console server:run -d public/
```

The server will then listen on `http://127.0.0.1:8000` (or, if port 8000 is
already in use, on the next free port after 8000).

You can stop the server with CTRL + C.

### Testing

Create test db with name phplist in your mysql DB or uncomment sqlite part in config_test.yml file to use in memory DB for functional tests.
To run the server in testing mode (which normally will only be needed for the
automated tests, provide the `--env` option:

```bash
bin/console server:run -d public/ --env=test
```

### Production

For documentation on running the application in production mode using Apache,
please see the
[phpList base distribution README](https://github.com/phpList/base-distribution).

## Changing the database schema

Any changes to the database schema must always be done both in phpList 3 and
later versions so that both versions always have the same schema.

For changing the database schema, please edit `resources/Database/Schema.sql`
and adapt the corresponding domain model classes and repository classes
accordingly.

## Developing phpList modules (plugins)

In phpList, plugins are called **modules**. They are Composer packages which
have the type `phplist-module`.

### Bundle and route configuration

If your module provides any Symfony bundles, the bundle class names need to be
listed in the `extra` section of the module's `composer.json` like this:

```json
{
"extra": {
"phplist/core": {
"bundles": [
"Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle",
"PhpList\\Core\\EmptyStartPageBundle\\PhpListEmptyStartPageBundle"
]
}
}
}
```

Please note that the key of the section with `extra` needs to always be
`phplist/core`, not the name of your module package. Please have a
look at the
[`composer.json` in the `rest-api` module](https://github.com/phpList/rest-api/blob/master/composer.json)
for an example.

Similarly, if your module provides any routes, those also need to be listed in
the `extra` section of the module's `composer.json` like this:

```json
{
"extra": {
"phplist/core": {
"routes": {
"homepage": {
"resource": "@PhpListEmptyStartPageBundle/Controller/",
"type": "annotation"
}
}
}
}
}
```

You can also provide system configuration for your module:

```json
{
"extra": {
"phplist/core": {
"configuration": {
"framework": {
"templating": {
"engines": [
"twig"
]
}
}
}
}
}
}
```

It is recommended to define the routes using
[annotations](https://symfony.com/doc/current/routing.html#routing-examples)
in the controller classes so that the route configuration in the composer.json
is minimal.

### Accessing the database

For accessing the phpList database tables from a module, please use the
[Doctrine](http://www.doctrine-project.org/) model and repository classes
stored in `src/Domain/` in the `phplist/core` package (this
package).

For accessing a repository, please have it injected via
[dependency injection](https://symfony.com/doc/current/components/dependency_injection.html).
Please do not get the repository directly from the entity manager as this would
skip dependency injection for that repository, causing those methods to break
that rely on other services having been injected.

Currently, only a few database tables are mapped as models/repositories. If you
need a mode or a repository method that still is missing, please
[submit a pull request](https://github.com/phpList/core/pulls) or
[file an issue](https://github.com/phpList/core/issues).

## Accessing the phpList data from third-party applications

To access the phpList data from a third-party application (i.e., not from a
phpList module), please use the
[REST API](https://github.com/phpList/rest-api).

## Translations

To extract translation strings from the source into an XLIFF catalog:

```bash
php bin/console translation:extract --force en --format=xlf
php bin/console messenger:setup-transports
php bin/console messenger:consume async_email --limit=1
php bin/console phplist:search:init-indices
```
Development:
* [Development guide](docs/Development.md) - running the web server, changing the database schema, translations
* [Developing phpList modules (plugins)](docs/ModuleDevelopment.md) - bundles, routes, database access, third-party access
* [Generating class API docs](PHPDOC.md) - regenerating the phpDocumentor output

## Copyright

phpList is copyright (C) 2000-2025 [phpList Ltd](https://www.phplist.com/).
phpList is copyright (C) 2000-2026 [phpList Ltd](https://www.phplist.com/).
56 changes: 29 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,36 @@
},
"require": {
"php": "^8.2",
"symfony/framework-bundle": "^6.4",
"symfony/dependency-injection": "^6.4",
"symfony/config": "^6.4",
"symfony/yaml": "^6.4",
"symfony/error-handler": "^6.4",
"symfony/serializer": "^6.4",
"symfony/framework-bundle": "^7.4",
"symfony/dependency-injection": "^7.4",
"symfony/config": "^7.4",
"symfony/yaml": "^7.4",
"symfony/error-handler": "^7.4",
"symfony/serializer": "^7.4",
"symfony/monolog-bundle": "^3.10",
"graylog2/gelf-php": "^2.0",
"symfony/serializer-pack": "^1.3",
"symfony/orm-pack": "^2.4",
"doctrine/orm": "^3.3",
"doctrine/cache": "^2.2",
"symfony/asset": "^6.4",
"symfony/security-csrf": "^6.4",
"symfony/form": "^6.4",
"symfony/validator": "^6.4",
"symfony/asset": "^7.4",
"symfony/security-csrf": "^7.4",
"symfony/form": "^7.4",
"symfony/validator": "^7.4",
"doctrine/doctrine-fixtures-bundle": "^3.7",
"doctrine/instantiator": "^2.0",
"masterminds/html5": "^2.9",
"ext-dom": "*",
"league/csv": "^9.23.0",
"doctrine/doctrine-migrations-bundle": "^3.4",
"symfony/mailer": "^6.4",
"symfony/google-mailer": "^6.4",
"symfony/amazon-mailer": "^6.4",
"symfony/mailchimp-mailer": "^6.4",
"symfony/sendgrid-mailer": "^6.4",
"symfony/twig-bundle": "^6.4",
"symfony/messenger": "^6.4",
"symfony/lock": "^6.4",
"symfony/mailer": "^7.4",
"symfony/google-mailer": "^7.4",
"symfony/amazon-mailer": "^7.4",
"symfony/mailchimp-mailer": "^7.4",
"symfony/sendgrid-mailer": "^7.4",
"symfony/twig-bundle": "^7.4",
"symfony/messenger": "^7.4",
"symfony/lock": "^7.4",
"webklex/php-imap": "^6.2",
"tatevikgr/rss-feed": "dev-main",
"ext-imap": "*",
Expand All @@ -88,24 +88,26 @@
"setasign/fpdf": "^1.8",
"phpdocumentor/reflection-docblock": "^5.2",
"guzzlehttp/guzzle": "^7.4.5",
"symfony/dotenv": "^6.4",
"symfony/doctrine-messenger": "^6.4",
"elasticsearch/elasticsearch": "^8.9"
"symfony/dotenv": "^7.4",
"symfony/doctrine-messenger": "^7.4",
"elasticsearch/elasticsearch": "^8.9",
"symfony/scheduler": "^7.4",
"symfony/requirements-checker": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.2.0",
"phpstan/phpstan": "^2.2",
"nette/caching": "^3.0.0",
"nikic/php-parser": "^4.19.1",
"nikic/php-parser": "^5.1",
"phpmd/phpmd": "^2.6.0",
"symfony/test-pack": "^1.1",
"symfony/process": "^6.4",
"symfony/process": "^7.4",
"composer/composer": "^2.7",
"symfony/http-kernel": "^6.4",
"symfony/http-foundation": "^6.4",
"symfony/routing": "^6.4",
"symfony/console": "^6.4",
"symfony/http-kernel": "^7.4",
"symfony/http-foundation": "^7.4",
"symfony/routing": "^7.4",
"symfony/console": "^7.4",
"psr/simple-cache": "^1.0 || ^2.0 || ^3.0",
"phpstan/phpstan-doctrine": "^2.0"
},
Expand Down
4 changes: 3 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ framework:
router:
resource: '%kernel.project_dir%/config/routing.yml'
strict_requirements: ~
property_info:
with_constructor_extractor: true
form: ~
csrf_protection: ~
validation:
Expand All @@ -44,4 +46,4 @@ framework:
php_errors:
log: true
mailer:
dsn: '%app.mailer_dsn%'
dsn: '%mailer.dsn%'
Loading
Loading