Compare commits

...

591 Commits

Author SHA1 Message Date
Alejandro Celaya
21ef1dfee8 Merge pull request #765 from acelaya-forks/feature/fix-dates-match
Feature/fix dates match
2020-05-11 13:27:38 +02:00
Alejandro Celaya
5ef548bc2a Updated changelog with v2.2.1 2020-05-11 13:19:01 +02:00
Alejandro Celaya
1fa9896524 Fixed error when trying to match creteria on a Short URL with dates 2020-05-11 13:12:55 +02:00
Alejandro Celaya
cb6756d801 Merge pull request #763 from shlinkio/develop
Release 2.2.0
2020-05-09 11:10:31 +02:00
Alejandro Celaya
cf605407ad Used definitive dependency versions for shlink-common and shlñink-installer 2020-05-09 10:56:07 +02:00
Alejandro Celaya
1a4eee1c81 Merge pull request #762 from acelaya-forks/feature/visits-by-tag
Feature/visits by tag
2020-05-09 10:52:33 +02:00
Alejandro Celaya
4c5cd88041 Updated changelog 2020-05-09 10:38:18 +02:00
Alejandro Celaya
4d346d1fea Created API test for tags visits endpoint 2020-05-09 10:31:39 +02:00
Alejandro Celaya
7f39e6d768 Created TagVisitsActionTest 2020-05-09 10:22:07 +02:00
Alejandro Celaya
9b9de8e290 Updated VisitsTrackerTest 2020-05-09 10:14:26 +02:00
Alejandro Celaya
e1e3c7f061 Created paginator adapter tests 2020-05-09 10:10:48 +02:00
Alejandro Celaya
3218f8c283 Added Created endpoint to serve visits by tag 2020-05-09 09:53:45 +02:00
Alejandro Celaya
f0acce1be0 Updated to latest common 2020-05-09 09:34:59 +02:00
Alejandro Celaya
dd4b4277c9 Added test for VisitRepository tag methods 2020-05-08 20:11:37 +02:00
Alejandro Celaya
baf77b6ffb Implemented methods to get paginated list of visits by tag, reusing methods used for short code filtering 2020-05-08 19:55:05 +02:00
Alejandro Celaya
5be882a31b Improved parameter definition in some private queries in VisitRepository 2020-05-08 19:41:21 +02:00
Alejandro Celaya
ae060f3b13 Merge pull request #761 from acelaya-forks/feature/optional-obfuscation
Feature/optional obfuscation
2020-05-08 16:03:11 +02:00
Alejandro Celaya
e8ab664561 Updated changelog 2020-05-08 15:54:50 +02:00
Alejandro Celaya
f4bf3551f6 Updated shlink-installer to a version supporting IP anonymization param 2020-05-08 15:50:16 +02:00
Alejandro Celaya
8f06e4b20f Replaced references to obfuscate by anonymize 2020-05-08 15:43:09 +02:00
Alejandro Celaya
bfdd6e0c50 Ensured SimplifiedConfigParser properly handles obfuscate_remote_addr option 2020-05-08 13:21:49 +02:00
Alejandro Celaya
ba13d99a71 Allowed remote addr obfuscation to be configured on docker image by using the OBFUSCATE_REMOTE_ADDR env var 2020-05-08 13:19:40 +02:00
Alejandro Celaya
eac468514b Allow to determine if remote addresses should be obfuscated at configuration level 2020-05-08 13:10:58 +02:00
Alejandro Celaya
7da00fbc8c Updated Visit entity so that the address can be optionally obfuscated 2020-05-08 12:58:49 +02:00
Alejandro Celaya
4b7c54d7a9 Merge pull request #760 from acelaya-forks/feature/list-tags-command
Updated ListTagsCommand so that it displays extended information
2020-05-08 12:57:35 +02:00
Alejandro Celaya
c336bb1901 Updated ListTagsCommand so that it displays extended information 2020-05-08 12:39:02 +02:00
Alejandro Celaya
fbb1c449da Merge pull request #759 from acelaya-forks/feature/improved-tags-endpoint
Feature/improved tags endpoint
2020-05-08 12:17:32 +02:00
Alejandro Celaya
252cc7f49d Updated changelog 2020-05-08 11:53:26 +02:00
Alejandro Celaya
00cac4ba72 Created rest test for list tags action 2020-05-08 11:51:28 +02:00
Alejandro Celaya
91aaffc6db Updated ListTagsActionTest 2020-05-08 11:32:06 +02:00
Alejandro Celaya
2e269bcacd Updated TagServiceTest 2020-05-08 11:14:39 +02:00
Alejandro Celaya
bdd14427d9 Added tests for TagRepository::findTagsWithInfo 2020-05-08 11:09:28 +02:00
Alejandro Celaya
06c59fe2dd Fixed invalid imports after class refactoring 2020-05-08 10:29:24 +02:00
Alejandro Celaya
9a78fd1a26 Fixed definition of inversed many to many entity relationship 2020-05-08 10:25:33 +02:00
Alejandro Celaya
626c92460b Enhanced list tags endpoint so that it can also return stats foir every tag 2020-05-08 10:15:33 +02:00
Alejandro Celaya
7e0a14493e Documented updates on the tags endpoint to return more detailed information 2020-05-08 10:14:38 +02:00
Alejandro Celaya
8d23e60d3a Merge pull request #758 from acelaya-forks/feature/non-stable-alpha
Ensured stable tag is not pushed when building docker image for alpha or beta versions
2020-05-07 10:57:52 +02:00
Alejandro Celaya
5f0293bc21 Ensured stable tag is not pushed when building docker image for alpha or beta versions 2020-05-07 10:45:53 +02:00
Alejandro Celaya
afe7381263 Merge pull request #757 from acelaya-forks/feature/docker-img-impr
Feature/docker img impr
2020-05-07 10:31:32 +02:00
Alejandro Celaya
b75922f1d3 Updated changelog 2020-05-07 10:17:34 +02:00
Alejandro Celaya
d9ae83a92b Updated everything related with dependencies in docker images 2020-05-07 10:16:20 +02:00
Alejandro Celaya
22cc9ace4d Merge pull request #755 from acelaya-forks/feature/fix-logged-remote-ip
Feature/fix logged remote ip
2020-05-05 13:04:02 +02:00
Alejandro Celaya
53a37feafe Updated changelogs 2020-05-05 12:54:08 +02:00
Alejandro Celaya
0cab51b01b Enforced mezzio-swoole 2.6.4 or greater 2020-05-05 12:51:47 +02:00
Alejandro Celaya
5f258b6a28 Merge pull request #752 from acelaya-forks/feature/travis-db-tests
Feature/travis db tests
2020-05-04 22:06:04 +02:00
Alejandro Celaya
cc41c51f77 Removed duplicated pdo_sqlsrv enabling on travis config 2020-05-04 21:55:18 +02:00
Alejandro Celaya
5f42266cf2 Moved ms odbc commands to a script 2020-05-04 21:48:54 +02:00
Alejandro Celaya
522d8ed236 Ensured some commands are run as sudo during travis CI 2020-05-04 21:33:19 +02:00
Alejandro Celaya
78359c28c7 Added MS ODBC package installation to travis 2020-05-04 21:22:41 +02:00
Alejandro Celaya
13bb48d068 Installed pdo_sqlsrv extension in travis 2020-05-04 21:12:49 +02:00
Alejandro Celaya
f6d9a83202 Moved initial ci databases to specific docker-compose file 2020-05-04 21:00:09 +02:00
Alejandro Celaya
dfdae96da5 Added commands to initially create all testing database for all database engines in travis 2020-05-04 20:34:28 +02:00
Alejandro Celaya
9f13063b1f Fixed docker-compose command run in travis 2020-05-04 20:02:48 +02:00
Alejandro Celaya
1e8c36b5f1 Updated changelog 2020-05-04 19:55:52 +02:00
Alejandro Celaya
e747a0b250 Updated how database tests are run in travis, so that all DB engines are covered 2020-05-04 19:55:03 +02:00
Alejandro Celaya
79b8834c61 Merge pull request #748 from acelaya-forks/feature/visits-perf-improvements
Feature/visits perf improvements
2020-05-03 20:11:40 +02:00
Alejandro Celaya
313b6a59b9 Updated changelog 2020-05-03 20:02:50 +02:00
Alejandro Celaya
d5288f756e Fixed entity mapping for visits without a visit location 2020-05-03 19:52:40 +02:00
Alejandro Celaya
867659ea25 Created index on visits.date column 2020-05-03 19:15:26 +02:00
Alejandro Celaya
74ad3553cb Hardcoded types on date fields when filtering visits lists 2020-05-03 19:02:13 +02:00
Alejandro Celaya
8b0ce8e6f3 Improved performance when loading visits chuncks at high offsets 2020-05-03 18:20:01 +02:00
Alejandro Celaya
0e4bccc4bb Cached result of the count query on VisitsPaginatorAdapter 2020-05-03 10:44:01 +02:00
Alejandro Celaya
c4ae89a279 Removed DISTINCT when counting visits for a short URL 2020-05-03 10:22:00 +02:00
Alejandro Celaya
80d41db901 Improved performance on query that returns the list of visits for a short URL 2020-05-02 22:47:59 +02:00
Alejandro Celaya
6c30fc73ee Added swoole reverse proxy container 2020-05-02 12:04:42 +02:00
Alejandro Celaya
56932e4ea6 Disabled swoole coroutines 2020-05-01 18:24:48 +02:00
Alejandro Celaya
84b38c4940 Merge pull request #745 from acelaya-forks/feature/general-visits
Feature/general visits
2020-05-01 12:16:22 +02:00
Alejandro Celaya
aece9e68ba Removed logger dependency from rest actions 2020-05-01 12:08:44 +02:00
Alejandro Celaya
d067f52ac2 Updated changelog 2020-05-01 11:58:59 +02:00
Alejandro Celaya
b5947d1642 Created more unit tests 2020-05-01 11:57:46 +02:00
Alejandro Celaya
3232ab401f Documented new visits endpoint 2020-05-01 11:44:55 +02:00
Alejandro Celaya
1ef10f11cb Created new action to get default visit stats 2020-05-01 11:40:02 +02:00
Alejandro Celaya
5beaab85ac Renamed GetVisitsAction to ShortUrlVisitsAction 2020-05-01 11:17:07 +02:00
Alejandro Celaya
4498386f56 Fixed merge conflicts 2020-04-30 20:26:00 +02:00
Alejandro Celaya
a30f796100 Merge pull request #743 from acelaya-forks/feature/geolite-license
Feature/geolite license
2020-04-30 19:34:44 +02:00
Alejandro Celaya
93a2c83652 Enabled GeoLite installer config option 2020-04-29 20:31:06 +02:00
Alejandro Celaya
4d4423413d Added GEOLITE_LICENSE_KEY env var to basic docker example, to encourage using it 2020-04-29 19:44:08 +02:00
Alejandro Celaya
a1c74c4038 Updated changelog 2020-04-29 19:31:10 +02:00
Alejandro Celaya
f71bb5e307 Added support for GEOLITE_LICENSE_KEY env var for docker image 2020-04-29 19:27:35 +02:00
Alejandro Celaya
9190996e54 Added support for geolite_license_key config option 2020-04-29 19:26:34 +02:00
Alejandro Celaya
af8b6b7f96 Documented how to pass a GEOLITE license key 2020-04-29 19:24:18 +02:00
Alejandro Celaya
704958994d Merge pull request #738 from acelaya-forks/feature/health-fix
Feature/health fix
2020-04-25 20:07:09 +02:00
Alejandro Celaya
a6864bca7c Updated changelog 2020-04-25 20:00:01 +02:00
Alejandro Celaya
15a8305209 Fixed random 503 responses from the HealthAction when the database connection injected on it has expired 2020-04-25 19:58:49 +02:00
Alejandro Celaya
469b70d708 Merge pull request #737 from acelaya-forks/feature/installation-error
Fixed error when cleaning metadata cache during installation with APC…
2020-04-25 19:30:06 +02:00
Alejandro Celaya
4f988d223b Fixed error when cleaning metadata cache during installation with APCu enabled 2020-04-25 19:13:47 +02:00
Alejandro Celaya
e95abc4efb Merge pull request #736 from acelaya-forks/feature/mercure-proxy
Configured an nginx container acting as a reverse proxy for the mercu…
2020-04-25 13:56:07 +02:00
Alejandro Celaya
4917e53acd Configured an nginx container acting as a reverse proxy for the mercure container 2020-04-25 13:44:09 +02:00
Alejandro Celaya
45db4c321a Merge pull request #731 from acelaya-forks/feature/fix-local-sqlite-tests
Ensured mysql config is not loaded for sqlite test envs
2020-04-18 14:06:44 +02:00
Alejandro Celaya
e6d914cfe1 Ensured mysql config is not loaded for sqlite test envs 2020-04-18 14:01:24 +02:00
Alejandro Celaya
85714c931d Merge pull request #730 from acelaya-forks/feature/fix-mysql-buffered-error
Feature/fix mysql buffered error
2020-04-18 13:29:24 +02:00
Alejandro Celaya
66a7f279c2 Updated changelog 2020-04-18 13:22:51 +02:00
Alejandro Celaya
7c6827ea9f Added MYSQL_ATTR_USE_BUFFERED_QUERY driver option with value true for mysql/maria connections 2020-04-18 13:21:46 +02:00
Alejandro Celaya
078c8ea011 Changed default mercure token duration to 1 day 2020-04-18 11:29:49 +02:00
Alejandro Celaya
655fd58a9d Added async API spec file 2020-04-16 22:44:08 +02:00
Alejandro Celaya
6ba6b951bf Changed mercure topics to be dash-cased 2020-04-16 22:25:12 +02:00
Alejandro Celaya
8e0e11f3b3 Merge pull request #727 from acelaya-forks/feature/mercure-improvement
Feature/mercure improvement
2020-04-14 21:16:16 +02:00
Alejandro Celaya
18b12ab1e6 Updated NotifyVisitToMercure to send both an update for all short URLs and one specific short URL 2020-04-14 20:57:25 +02:00
Alejandro Celaya
3908f63b0d Updated to latest installer version 2020-04-14 20:30:05 +02:00
Alejandro Celaya
ca2c32fa8c Removed no-longer used dependencies 2020-04-14 20:24:36 +02:00
Alejandro Celaya
a3a3ac1859 Added missing escaped characters 2020-04-13 13:23:26 +02:00
Alejandro Celaya
f5e0d0c2b1 Merge pull request #726 from acelaya-forks/feature/mercure-integration
Feature/mercure integration
2020-04-13 10:03:12 +02:00
Alejandro Celaya
ba0678946f Updated installer to use a version supporting mercure options 2020-04-13 09:38:18 +02:00
Alejandro Celaya
934fa937b5 Updated config parsers for docker image to accept new mercure env vars and configs 2020-04-12 20:41:23 +02:00
Alejandro Celaya
8d888cb43d Documented how to use a mercure hub when using the docker image 2020-04-12 18:39:28 +02:00
Alejandro Celaya
7f888c49b4 Created MercureUpdatesGeneratorTest 2020-04-12 18:01:13 +02:00
Alejandro Celaya
e97dfbfdda Created NotifyVisitToMercureTest 2020-04-12 17:50:40 +02:00
Alejandro Celaya
b858d79b9e Fixed mercure hub URL returned by MercureInfoAction 2020-04-12 17:50:09 +02:00
Alejandro Celaya
72d8edf4ff Created event listener that notifies mercure hub for new visits 2020-04-12 17:05:59 +02:00
Alejandro Celaya
31db97228d Created MercureInfoActionTest 2020-04-12 14:22:23 +02:00
Alejandro Celaya
2ffbf03cf8 Created action to get mercure integration info 2020-04-12 13:59:10 +02:00
Alejandro Celaya
85440c1c5f Improved mercure-related configs 2020-04-12 12:21:05 +02:00
Alejandro Celaya
69962f1fe8 Added package to handle JWTs 2020-04-11 18:10:56 +02:00
Alejandro Celaya
10cad33248 Added configuration for mercure integration 2020-04-11 18:10:56 +02:00
Alejandro Celaya
0c9deca3f8 Added symfony/mercure package and a container for development 2020-04-11 18:10:56 +02:00
Alejandro Celaya
e1cd4a6ee3 Merge pull request #724 from acelaya-forks/feature/clean-tasks
Created decorator for database connection closing and reopening for s…
2020-04-11 18:09:26 +02:00
Alejandro Celaya
f915b97606 Created decorator for database connection closing and reopening for swoole tasks 2020-04-11 18:00:40 +02:00
Alejandro Celaya
e775b0f12f Merge pull request #722 from shlinkio/develop
Release 2.1.3
2020-04-09 12:50:46 +02:00
Alejandro Celaya
3ee5853b32 Merge pull request #721 from acelaya-forks/feature/qr-code-links
Feature/qr code links
2020-04-09 12:40:05 +02:00
Alejandro Celaya
832a24e4c7 Updated changelog 2020-04-09 12:33:00 +02:00
Alejandro Celaya
551368c30d Ensured QR code action respects configured domain 2020-04-09 12:31:03 +02:00
Alejandro Celaya
9f24b8eb76 Merge pull request #720 from acelaya-forks/feature/db-conn-recovery-task-workers
Feature/db conn recovery task workers
2020-04-09 12:01:47 +02:00
Alejandro Celaya
4c83ae2b22 Updated changelog 2020-04-09 11:55:47 +02:00
Alejandro Celaya
28e0fb049b Added check to ensure DB connection is gracefully recovered on swoole task workers 2020-04-09 11:54:54 +02:00
Alejandro Celaya
f79a369884 Merge pull request #719 from acelaya-forks/feature/handle-HEAD-requests
Feature/handle head requests
2020-04-09 00:06:28 +02:00
Alejandro Celaya
34c7b870a7 Removed unnecessary service registration, as it comes preregistered from third party config provider 2020-04-08 23:56:39 +02:00
Alejandro Celaya
ec9f874bb9 Updated changelog 2020-04-08 23:53:23 +02:00
Alejandro Celaya
1980d35691 Ensured redirect requests are not tracked when request is performed using method HEAD 2020-04-08 23:51:57 +02:00
Alejandro Celaya
ec8cbf82e5 Added HEAD request implicit handling 2020-04-08 17:27:26 +02:00
Alejandro Celaya
2b1011de52 Merge pull request #714 from acelaya-forks/feature/metadata-cache-clear
Feature/metadata cache clear
2020-04-06 21:08:46 +02:00
Alejandro Celaya
fa9ace83ad Fixed incorrect use of tilde 2020-04-06 20:59:10 +02:00
Alejandro Celaya
a9a53a9652 Ensured entities metadata cache is cleared during installation and docker start-up 2020-04-06 20:52:33 +02:00
Alejandro Celaya
afca8b2a62 Merge pull request #704 from shlinkio/develop
Release v2.1.2
2020-03-29 13:23:41 +02:00
Alejandro Celaya
daeb293fb9 Merge pull request #703 from acelaya-forks/feature/infection-0.16
Feature/infection 0.16
2020-03-29 13:14:07 +02:00
Alejandro Celaya
1ca50a4a8a Updated changelog 2020-03-29 13:08:21 +02:00
Alejandro Celaya
c6602a81ab Updated to infection 0.16 2020-03-29 13:07:27 +02:00
Alejandro Celaya
46da0e7824 Merge pull request #702 from acelaya-forks/feature/fix-tags-filtering
Feature/fix tags filtering
2020-03-29 13:00:06 +02:00
Alejandro Celaya
e790a38cea Updated changelog 2020-03-29 12:54:09 +02:00
Alejandro Celaya
11879ea377 Ensured tags are not sluggified when using them to filter short URL lists 2020-03-29 12:51:39 +02:00
Alejandro Celaya
7105add009 Merge pull request #701 from acelaya-forks/feature/fix-migration
Fixed query in migration for postgres
2020-03-29 12:25:19 +02:00
Alejandro Celaya
af61fdb52d Updated changelog 2020-03-29 12:15:52 +02:00
Alejandro Celaya
2b4fc354db Fixed query in migration for postgres 2020-03-29 12:13:52 +02:00
Alejandro Celaya
5b72001a8c Merge pull request #699 from shlinkio/develop
V2.1.1
2020-03-28 20:14:35 +01:00
Alejandro Celaya
7c79906ac4 Merge pull request #698 from acelaya-forks/feature/2.1.1
Feature/2.1.1
2020-03-28 20:03:09 +01:00
Alejandro Celaya
e30a724529 Make sure dist files include the htaccess file 2020-03-28 19:54:02 +01:00
Alejandro Celaya
73f97ea874 Ensured releases are published to github before the docker image is built 2020-03-28 19:48:06 +01:00
Alejandro Celaya
09c155b7d3 Merge pull request #695 from shlinkio/develop
v2.1.0
2020-03-28 12:23:41 +01:00
Alejandro Celaya
1e2d115768 Merge pull request #694 from acelaya-forks/feature/process-retry
Feature/process retry
2020-03-28 12:06:09 +01:00
Alejandro Celaya
53ba58d7e9 Moved initialization of the io object in LocateVisitsCommand to the initialize method 2020-03-28 10:37:41 +01:00
Alejandro Celaya
2a30afbe7d Updated changelog 2020-03-28 10:29:12 +01:00
Alejandro Celaya
4d39c7041b Improved LocateVisitsCommandtest so that it covers all possible workflows 2020-03-28 10:23:34 +01:00
Alejandro Celaya
c012b4740d Updated VisitLocator test so that it covers all public methods 2020-03-28 10:01:09 +01:00
Alejandro Celaya
55778eb810 Ensured old visit locations are deleted when relocating a visit that has already been located 2020-03-28 09:27:45 +01:00
Alejandro Celaya
fb8ab0b5fe Implemented how to reprocess the locations of all existing visits 2020-03-28 09:12:15 +01:00
Alejandro Celaya
fcce18b059 Changed VisitLocator signature so that it expects an object implementing an interface instead of two arbitrary callbacks 2020-03-28 08:05:15 +01:00
Alejandro Celaya
43a3d469e7 Improved how visits with some conditions are fetched from the database, so all internal logic is 100% transparent regardless the purpose 2020-03-27 22:01:26 +01:00
Alejandro Celaya
f730c24ecb Created method to return visits with empty location 2020-03-26 22:56:53 +01:00
Alejandro Celaya
b8522b8c17 Created new method to locate empty visits 2020-03-26 22:37:46 +01:00
Alejandro Celaya
b0d96040be Merge pull request #691 from Lynnesbian/develop
Update sample Nginx config to point to PHP 7.4
2020-03-25 08:49:36 +01:00
Lynne
5554675d03 Update sample Nginx config to point to PHP 7.4 2020-03-25 16:48:44 +10:00
Alejandro Celaya
c88401ef29 Added isEmpty column to VisitLocation 2020-03-23 20:42:03 +01:00
Alejandro Celaya
75f77ed929 Merge pull request #689 from acelaya-forks/feature/fake-class-constant
Moved hardcoded class alias to a namespaced constant
2020-03-22 17:50:57 +01:00
Alejandro Celaya
4539ab2dcf Moved hardcoded class alias to a namespaced constant 2020-03-22 17:42:56 +01:00
Alejandro Celaya
9ad0561cac Merge pull request #688 from acelaya-forks/feature/edit-long-url
Feature/edit long url
2020-03-22 17:38:00 +01:00
Alejandro Celaya
774052a983 Updated changelog 2020-03-22 17:31:16 +01:00
Alejandro Celaya
3beb27acc2 Added API tests for the edition of the longURL 2020-03-22 17:30:01 +01:00
Alejandro Celaya
5432eb7b77 Added URL validation to ShortUrl edition, as long URL can now be edited 2020-03-22 17:22:52 +01:00
Alejandro Celaya
181ff16409 Registered PersistenceDomainResolver as a service to avoid instantiating a new one on every ShortUrl creation 2020-03-22 17:05:59 +01:00
Alejandro Celaya
682a0768b7 Moved check for URL validation config option to the UrlValidator itself 2020-03-22 16:58:28 +01:00
Alejandro Celaya
d29ebb706e Documented longUrl param on PATCH short URL endpoint 2020-03-22 14:06:13 +01:00
Alejandro Celaya
4e6836c605 Long URLs can now be edited on existing short URLs 2020-03-22 14:04:01 +01:00
Alejandro Celaya
59c0d36c0b Merge pull request #687 from acelaya-forks/feature/real-ip-geolocation
Feature/real ip geolocation
2020-03-22 11:55:02 +01:00
Alejandro Celaya
e10b2884c0 Added more exclussions to dockerignore 2020-03-22 11:33:00 +01:00
Alejandro Celaya
8fb54e815e Ensured scrutinizer build ignores platform requirements when installing dependencies 2020-03-22 11:27:03 +01:00
Alejandro Celaya
3a14483568 Updated changelog 2020-03-22 11:13:33 +01:00
Alejandro Celaya
fdd8efc12d Added test covering case in which the original address is provided when locating visits 2020-03-22 11:12:30 +01:00
Alejandro Celaya
3fef4b4a28 Ensured non-obfuscated IP address is passed to event listener which geolocates it 2020-03-22 10:48:27 +01:00
Alejandro Celaya
cea50a860e Improved docker image generation 2020-03-22 10:01:34 +01:00
Alejandro Celaya
f9318bb1b3 Merge pull request #686 from acelaya-forks/feature/reduce-docker-image
Feature/reduce docker image
2020-03-21 16:21:25 +01:00
Alejandro Celaya
d22f020eb5 Ensured more non-prod files are ignored/deleted from the final docker image 2020-03-21 16:11:56 +01:00
Alejandro Celaya
c556d8123b Fixed name of the build arg passed when building docker for a specific tag 2020-03-21 15:43:52 +01:00
Alejandro Celaya
a592833bd0 Merge pull request #685 from acelaya-forks/feature/fix-docker-build
Ensured docker build happens in all branches
2020-03-21 15:36:18 +01:00
Alejandro Celaya
881da3db3b Ensured docker build happens in all branches 2020-03-21 15:31:14 +01:00
Alejandro Celaya
32eb9924e5 Merge pull request #684 from acelaya-forks/feature/travis-docker-build
Feature/travis docker build
2020-03-21 15:14:14 +01:00
Alejandro Celaya
d2c06dd0ab Initialized typed nullable props as null in all entities 2020-03-21 14:38:24 +01:00
Alejandro Celaya
75b8ed813f Enforced Swoole 4.4.15 to be installed during travis build, to match production one 2020-03-21 14:25:19 +01:00
Alejandro Celaya
f811002c2b Small adjustments on docker build 2020-03-21 09:37:31 +01:00
Alejandro Celaya
ca1b17863c Split Dockerfile into multiple stages, making the build be independent and then the released image just copy files from it 2020-03-21 09:10:15 +01:00
Alejandro Celaya
644f5be6fe Added scripts and configs to build docker image on travis 2020-03-21 08:42:13 +01:00
Alejandro Celaya
65fbb1dfb3 Merge pull request #680 from acelaya-forks/feature/non-interactive-db-commands
Feature/non interactive db commands
2020-03-15 17:32:57 +01:00
Alejandro Celaya
8597966187 Updated changelog 2020-03-15 17:26:34 +01:00
Alejandro Celaya
6ddd70d21d Added --no-interaction to commands run internally from shlink DB commands 2020-03-15 17:25:39 +01:00
Alejandro Celaya
d32112fe7e Updated shlink packages and installed shlink-config 2020-03-15 17:14:37 +01:00
Alejandro Celaya
da858f0353 Merge branch 'develop' of github.com:shlinkio/shlink into develop 2020-03-10 21:45:57 +01:00
Alejandro Celaya
ba8b041698 Updated API docs links 2020-03-10 21:45:20 +01:00
Alejandro Celaya
d9fee5582a Added docker pulls badge to main readme file 2020-03-07 08:44:12 +01:00
Alejandro Celaya
c9f17d54ee Merge pull request #676 from acelaya-forks/feature/bar-slug
Feature/bar slug
2020-03-06 20:09:59 +01:00
Alejandro Celaya
f5c1e12db4 Added more tests covering invalid custom slugs 2020-03-06 20:01:41 +01:00
Alejandro Celaya
18ceafeb60 Ensured only empty strings are checked while verifying empty value on custom slug 2020-03-06 19:25:05 +01:00
Alejandro Celaya
67e93a6874 Ensured empty values cannot be provided as the custom slug 2020-03-06 19:20:33 +01:00
Alejandro Celaya
f6a83a3062 Merge pull request #670 from acelaya-forks/feature/base-url-redirect
Feature/base url redirect
2020-02-25 18:06:47 +01:00
Alejandro Celaya
8a0e902bdd Updated changelog 2020-02-25 18:02:38 +01:00
Alejandro Celaya
590fc3fc92 Added tests covering redirect simplified config parsing 2020-02-25 18:01:06 +01:00
Alejandro Celaya
0d54b7696f Merge pull request #669 from jpatters/fix/base_url_redirect_to
fixed incorrect configuration option for base_url_redirect_to
2020-02-25 17:58:58 +01:00
Jordan Patterson
6b1dadc35c fixed incorrect configuration option for base_url_redirect_to 2020-02-25 06:47:02 -08:00
Alejandro Celaya
86009543ed Merge pull request #662 from acelaya-forks/feature/rest-request-id
Feature/rest request
2020-02-21 19:54:30 +01:00
Alejandro Celaya
b728a78673 Updated changelog 2020-02-21 19:47:30 +01:00
Alejandro Celaya
fb89cb80ac Added formatting to swoole logs, to avoid duplicating the date 2020-02-19 19:48:48 +01:00
Alejandro Celaya
d0a986dd5a Added request ID to logs with monolog 2020-02-19 19:37:47 +01:00
Alejandro Celaya
bb231e668b Registered middleware generating request ID 2020-02-19 18:58:25 +01:00
Alejandro Celaya
f53fa5c90f Merge pull request #660 from acelaya-forks/feature/short-codes-length
Feature/short codes length
2020-02-18 20:42:37 +01:00
Alejandro Celaya
1f3e0d1f73 Updated changelog 2020-02-18 20:35:41 +01:00
Alejandro Celaya
33a404f051 Updated CLI command to create short URLs so that it respects configs for short code length 2020-02-18 20:34:48 +01:00
Alejandro Celaya
51e130c7a0 Added env var that can be used to define default short codes length on docker image 2020-02-18 19:34:01 +01:00
Alejandro Celaya
343ee04acb Created middleware which injects default short code length from config when a value was not explicitly provided 2020-02-18 19:21:34 +01:00
Alejandro Celaya
9372d1739a Enforced short URLs length to be 4 at least 2020-02-18 18:57:24 +01:00
Alejandro Celaya
13555366e3 Short code lengths can now be customized 2020-02-18 18:54:40 +01:00
Alejandro Celaya
8162dafe16 Added separator in readme before MaxMind reference 2020-02-16 12:18:23 +01:00
Alejandro Celaya
0b6602b275 Merge pull request #659 from acelaya-forks/feature/phpunit9
Feature/phpunit9
2020-02-15 21:21:00 +01:00
Alejandro Celaya
2cf9f64e8e Updated changelog 2020-02-15 21:14:55 +01:00
Alejandro Celaya
37c0a813db Updated to PHPUnit 9 2020-02-15 21:14:14 +01:00
Alejandro Celaya
a9269811dc Added command to run api tests with code coverage 2020-02-15 20:55:04 +01:00
Alejandro Celaya
0b353737ea Merge pull request #658 from acelaya-forks/feature/mssql
Feature/mssql
2020-02-15 20:39:20 +01:00
Alejandro Celaya
a3fc1513e1 Updated Installer to include the one supporting MsSQL 2020-02-15 20:28:32 +01:00
Alejandro Celaya
5886d73093 Documented support for Microsoft SQL Server 2020-02-14 19:55:24 +01:00
Alejandro Celaya
12adce9ac2 Updated changelog 2020-02-14 19:51:58 +01:00
Alejandro Celaya
d8cbf0512b Added missing env var which fixes issues with mssql driver on alpine 2020-02-14 19:44:11 +01:00
Alejandro Celaya
2bb2c2cde3 Documented how to use mssql with the docker image 2020-02-14 19:27:21 +01:00
Alejandro Celaya
27fd9c5988 Added MSSQL driver to prod docker image 2020-02-14 19:20:54 +01:00
Alejandro Celaya
542673fcb0 Updated development docker images 2020-02-14 19:11:29 +01:00
Alejandro Celaya
e60d80bb16 Merge pull request #655 from shlinkio/develop
Release v2.0.5
2020-02-09 18:07:55 +01:00
Alejandro Celaya
bb9e57fa8b Added support for mssql on dev env 2020-02-09 18:01:11 +01:00
Alejandro Celaya
1d4bea68af Updated changelog 2020-02-09 17:59:01 +01:00
Alejandro Celaya
d2f9f5fd5e Merge pull request #654 from acelaya-forks/feature/domain-docs
Feature/domain docs
2020-02-08 19:02:39 +01:00
Alejandro Celaya
f13c3364eb Updated changelog 2020-02-08 18:52:48 +01:00
Alejandro Celaya
ac04bedead Documented how Shlink behaves when using multiple domains 2020-02-08 18:52:02 +01:00
Alejandro Celaya
67a66cefa6 Merge pull request #653 from acelaya-forks/feature/remove-default-domain-from-body
Feature/remove default domain from body
2020-02-08 12:38:20 +01:00
Alejandro Celaya
43db066cb4 Updated changelog 2020-02-08 12:31:25 +01:00
Alejandro Celaya
faec758fba Added test to ensure default domain is ignored if provided when creatin a short URL 2020-02-08 12:30:47 +01:00
Alejandro Celaya
ccec6e03aa Updated middleware which drops default domain so that it is capable of doing it from parsed body too 2020-02-08 12:22:07 +01:00
Alejandro Celaya
3f08b38558 Merge pull request #652 from acelaya-forks/feature/fix-logs-permissions
Feature/fix logs permissions
2020-02-08 11:58:09 +01:00
Alejandro Celaya
1ee5f64738 Updated changelog 2020-02-08 11:51:39 +01:00
Alejandro Celaya
d22169803f Ensured any user can write in generated log files 2020-02-08 11:50:25 +01:00
Alejandro Celaya
57807c4360 Merge pull request #647 from shlinkio/develop
Release v2.0.4
2020-02-02 20:23:09 +01:00
Alejandro Celaya
6e1d07b0cc Merge pull request #646 from acelaya-forks/feature/search-on-domains
Feature/search on domains
2020-02-02 20:14:27 +01:00
Alejandro Celaya
0c0349fa39 Fixed version on changelog 2020-02-02 20:09:30 +01:00
Alejandro Celaya
8d8a0f2484 Updated changelog 2020-02-02 20:08:22 +01:00
Alejandro Celaya
8ff913aaf2 Ensured search terms are applied to the domain too 2020-02-02 20:07:19 +01:00
Alejandro Celaya
f7d54abb2b Merge pull request #645 from acelaya-forks/feature/multi-domain-fixes
Feature/multi domain fixes
2020-02-02 19:28:21 +01:00
Alejandro Celaya
ce990c67e3 Fixed coding styles 2020-02-02 19:19:35 +01:00
Alejandro Celaya
907b8453c6 Updated changelog 2020-02-02 19:16:53 +01:00
Alejandro Celaya
8a0ba11f79 Added one more test case for not found URLs on API tests 2020-02-02 19:15:14 +01:00
Alejandro Celaya
0c1ecd3caa Created DropDefaultDomainFromQueryMiddlewareTest 2020-02-02 19:13:32 +01:00
Alejandro Celaya
c07c37f7bd Created middleware to drop domain from query when it is the default one 2020-02-02 19:03:43 +01:00
Alejandro Celaya
fe652c67f4 Covered with API tests getting invalid short URLs by short code and domain 2020-02-02 13:15:08 +01:00
Alejandro Celaya
297985cf01 Ensured trying to fetch a short URL for any operation through the API results in 404 if it does not match with porovided domain 2020-02-02 12:58:26 +01:00
Alejandro Celaya
10f79ec01d Created new repository method which will look for short URLs without doing domain fallback 2020-02-02 12:44:35 +01:00
Alejandro Celaya
e87d4d61bc Added API test for editing tags with and without domain 2020-02-02 10:53:49 +01:00
Alejandro Celaya
e58f2a384e Added API test for visits with and without domain 2020-02-02 10:46:38 +01:00
Alejandro Celaya
881002634a Added API tests for short URL deletion with domain 2020-02-02 10:28:10 +01:00
Alejandro Celaya
aa80c2bb82 Updated API tests so that fixture short URLs are created with matching short codes and different domains 2020-02-02 09:51:17 +01:00
Alejandro Celaya
75cd9774b7 Added optional domain query param to documentation for all rest endpoints that need it 2020-02-02 09:15:43 +01:00
Alejandro Celaya
1a8e4cdfd7 Exposed domain on short URLs 2020-02-02 08:57:04 +01:00
Alejandro Celaya
6858dc4785 Updated setting short URL tags so that it accepts providing the domain 2020-02-01 22:59:21 +01:00
Alejandro Celaya
5d1d9dcac3 Allowed domain to be provided when editing short URL meta 2020-02-01 22:54:21 +01:00
Alejandro Celaya
732bb06c62 Updated short URL deletion so that it accepts the domain 2020-02-01 18:06:50 +01:00
Alejandro Celaya
5f00d8b732 Added domain flag to GetVisitsCommand 2020-02-01 17:56:43 +01:00
Alejandro Celaya
a3ff545d43 Improved VisitsRepositoryTest to cover fetching visits for URL with domain 2020-02-01 17:44:37 +01:00
Alejandro Celaya
279bd12a2d Ensured domain can be passed when fetching visits for a short URL 2020-02-01 17:34:16 +01:00
Alejandro Celaya
1b2a0d674f Fixed correct short URL being tracked when domain exists 2020-02-01 13:03:48 +01:00
Alejandro Celaya
fd82de31c0 Fixed the way ShortUrlIdentifier is created from requests, on different request scopes 2020-02-01 12:54:10 +01:00
Alejandro Celaya
327d35fe57 Created DTO used to transfer props needed to uniquely identify a short URL 2020-02-01 11:47:01 +01:00
Alejandro Celaya
e18187f04e Merge pull request #636 from acelaya-forks/feature/postgres-schema-support
Feature/postgres schema support
2020-01-29 11:02:23 +01:00
Alejandro Celaya
bd2f488e2c Updated entity mappings so that schema an table prefixes can be eventually provided 2020-01-29 10:53:06 +01:00
Alejandro Celaya
96350c8b8f Updated entities mapping config so that they return a function 2020-01-29 10:06:42 +01:00
Alejandro Celaya
a737eed5c5 Merge pull request #634 from acelaya-forks/feature/simplify-error-logs
Updated to shlink-common 2.6
2020-01-28 18:23:37 +01:00
Alejandro Celaya
9b2ccaeb7b Updated to shlink-common 2.6 2020-01-28 18:11:39 +01:00
Alejandro Celaya
304979273f Merge pull request #633 from acelaya-forks/feature/list-filtering-dto
Feature/list filtering dto
2020-01-28 13:05:24 +01:00
Alejandro Celaya
7add41d560 Ensured BC on dates for short urls params 2020-01-28 12:57:21 +01:00
Alejandro Celaya
51ebe57ac8 Updated changelog 2020-01-28 12:12:50 +01:00
Alejandro Celaya
6ff5a532ea Added extra API test covering complex order by for short URL lists 2020-01-28 11:20:48 +01:00
Alejandro Celaya
fccd92497a Added last check on ShortUrlsOrdering which makes sure everything keeps behaving as it used to 2020-01-28 11:17:54 +01:00
Alejandro Celaya
452bfea088 Created DTOs with implicit validation to wrap short URLs lists params 2020-01-28 10:49:55 +01:00
Alejandro Celaya
240d2588f9 Extracted some private functions ase helper global functions 2020-01-28 09:41:48 +01:00
Alejandro Celaya
eca7800487 Merge pull request #632 from shlinkio/develop
Release v2.0.3
2020-01-27 11:44:43 +01:00
Alejandro Celaya
b9e58b9300 Merge pull request #631 from acelaya-forks/feature/permission-denied
Feature/permission denied
2020-01-27 11:37:37 +01:00
Alejandro Celaya
54918db9ef Updated changelog 2020-01-27 11:31:44 +01:00
Alejandro Celaya
b07a603456 Updated dependencies 2020-01-27 11:30:29 +01:00
Alejandro Celaya
4fb2c64fa8 Merge pull request #630 from acelaya-forks/feature/fetch-not-visitable-url
Feature/fetch not visitable url
2020-01-26 20:00:47 +01:00
Alejandro Celaya
258c4102be Updated changelog 2020-01-26 19:55:03 +01:00
Alejandro Celaya
b9c7f8e8d4 Added unit tests for ShortUrlresolver 2020-01-26 19:53:18 +01:00
Alejandro Celaya
f32e7cc7c4 Removed tests checking domain logic from ShortUrlRepositoryTest 2020-01-26 19:25:41 +01:00
Alejandro Celaya
4ebd48b2b0 Created new service to resolve short URLs 2020-01-26 19:21:51 +01:00
Alejandro Celaya
f71bd84a20 Merge pull request #629 from acelaya-forks/feature/reset-meta
Feature/reset meta
2020-01-26 09:49:36 +01:00
Alejandro Celaya
33b45eb620 Updated changelog 2020-01-26 09:37:43 +01:00
Alejandro Celaya
1f9a912c04 Added API tests covering the edition of short URL meta with resetted values 2020-01-26 09:29:04 +01:00
Alejandro Celaya
45151cdde6 Standardized how the ShortUrlMeta object is created by exposing a single named constructor 2020-01-26 08:42:51 +01:00
Alejandro Celaya
8ca45eb388 Merge pull request #627 from acelaya-forks/feature/remote-ip-order
Feature/remote ip order
2020-01-24 21:28:39 +01:00
Alejandro Celaya
b7a34a6640 Updated changelog 2020-01-24 21:21:13 +01:00
Alejandro Celaya
8ec686f4e2 Updated order in which headers for remote IP detection are inspected 2020-01-24 21:19:40 +01:00
Alejandro Celaya
43fc655218 Merge pull request #618 from shlinkio/develop
Release v2.0.2
2020-01-12 11:02:10 +01:00
Alejandro Celaya
f5a30c4c2d Merge pull request #617 from acelaya-forks/feature/fix-urls-with-hash
Feature/fix urls with hash
2020-01-12 10:38:25 +01:00
Alejandro Celaya
af1dd78b2c Fixed typo 2020-01-12 10:32:03 +01:00
Alejandro Celaya
fc95986f0e Updated changelog for v2.0.2 2020-01-12 10:30:14 +01:00
Alejandro Celaya
c52794aed6 Replaced standard http_build_query by guzzle's build_query, which keeps params with no value 2020-01-12 10:28:44 +01:00
Alejandro Celaya
15a72e2a88 Updated local config files which were not fulfilling the project's coding standards 2020-01-12 10:06:45 +01:00
Alejandro Celaya
94af588a3c Merge pull request #616 from acelaya-forks/feature/successful-options-req
Feature/successful options req
2020-01-12 09:36:18 +01:00
Alejandro Celaya
0a4f3bc0f5 Updated changelog 2020-01-11 20:38:10 +01:00
Alejandro Celaya
09e3464426 Ensured CrossDomainMiddleware always returns empty responses with success status on OPTIONS requests 2020-01-11 20:36:17 +01:00
Alejandro Celaya
7fcc4ebd57 Merge pull request #613 from shlinkio/develop
Releasing v2.0.1
2020-01-10 19:56:56 +01:00
Alejandro Celaya
b246815529 Merge pull request #612 from acelaya-forks/feature/avoid-nulls
Feature/avoid nulls
2020-01-10 19:51:02 +01:00
Alejandro Celaya
ad1334f289 Created database migration which ensures no nulls are present 2020-01-10 19:44:35 +01:00
Alejandro Celaya
49bccf9a06 Updated changelog 2020-01-10 19:20:44 +01:00
Alejandro Celaya
1a8bf54e8b Merge pull request #611 from acelaya-forks/feature/db-migrate-syntax-error
Feature/db migrate syntax error
2020-01-10 19:17:45 +01:00
Alejandro Celaya
96bb0321eb Updated casting type so that it is dynamic 2020-01-10 19:08:23 +01:00
Alejandro Celaya
37f0abf86f Fixed use of hardcoded quotes on database migration, making it crash on postgres 2020-01-10 18:40:49 +01:00
Alejandro Celaya
f9119a38b3 Updated changelog 2020-01-10 16:04:35 +01:00
Alejandro Celaya
8465a9da31 Merge pull request #608 from acelaya-forks/feature/missing-upgrade+info
Added missing information in upgrading document
2020-01-09 07:48:27 +01:00
Alejandro Celaya
b6b0d09647 Added missing information in upgrading document 2020-01-09 07:37:59 +01:00
Alejandro Celaya
3d2932782d Merge pull request #604 from shlinkio/develop
Release v2
2020-01-08 19:46:53 +01:00
Alejandro Celaya
fa2fede604 Updated docker docs 2020-01-08 19:37:12 +01:00
Alejandro Celaya
3aded3bc5f Updated changelog tagging v2.0.0 2020-01-08 19:17:02 +01:00
Alejandro Celaya
2d4cc912b7 Required proxy-manager 2.6 2020-01-07 18:27:32 +01:00
Alejandro Celaya
c0881f9292 Merge pull request #603 from acelaya-forks/feature/versioned-health
Feature/versioned health
2020-01-07 18:15:17 +01:00
Alejandro Celaya
302a77b9dd Updated changelog 2020-01-07 18:10:09 +01:00
Alejandro Celaya
2b544ad141 Refactored Rest ConfigProvider so that it appends the health action with and without version 2020-01-07 18:07:51 +01:00
Alejandro Celaya
36d5e057d0 Ensured the health action is registered bit with and without version 2020-01-06 23:32:43 +01:00
Alejandro Celaya
96eb6a80e1 Merge pull request #599 from acelaya-forks/feature/update-shlink-packages
Feature/update shlink packages
2020-01-06 23:19:52 +01:00
Alejandro Celaya
9c5f5a46b5 Replaced use of deprecated class by a non-deprecated one 2020-01-06 23:08:14 +01:00
Alejandro Celaya
886f63d3e4 Workarounded doctrine-dbal issue by creating new columns instead of changing column types 2020-01-06 22:57:10 +01:00
Alejandro Celaya
7748dd7cef Ensured latitude and longitude are set as float in DB 2020-01-06 22:31:00 +01:00
Alejandro Celaya
2e0f8067aa Enabled redis config option 2020-01-05 17:04:22 +01:00
Alejandro Celaya
4fadd523f1 Updated config to read redis from config.redis 2020-01-05 16:45:14 +01:00
Alejandro Celaya
abe54c67d8 Updated changelog 2020-01-04 13:21:37 +01:00
Alejandro Celaya
f3f35218c3 Updated to installer v4 2020-01-04 13:18:28 +01:00
Alejandro Celaya
b9eb9cb6d9 Updated all shlink packages but installer to their latest version 2020-01-03 11:38:21 +01:00
Alejandro Celaya
40c014b663 Fixed merge conflicts 2020-01-02 22:58:40 +01:00
Alejandro Celaya
70f1db4e94 Merge pull request #597 from acelaya-forks/hotfix/1.21.1
Updated URL from which GeoLite DB is downloaded
2020-01-02 22:55:45 +01:00
Alejandro Celaya
2fff38d51a Added v1.21.1 to changelog 2020-01-02 22:49:17 +01:00
Alejandro Celaya
32de74b23e Updated URL from which GeoLite DB is downloaded 2020-01-02 22:46:56 +01:00
Alejandro Celaya
c96d24cc0b Merge pull request #595 from acelaya-forks/feature/laminas
Feature/laminas
2020-01-01 21:26:33 +01:00
Alejandro Celaya
824ee55d38 Updated changelog 2020-01-01 21:16:26 +01:00
Alejandro Celaya
86e701dccc Updated local config file 2020-01-01 21:15:23 +01:00
Alejandro Celaya
2151b97bec Project migrated from zend to laminas 2020-01-01 21:13:09 +01:00
Alejandro Celaya
18312b0624 Merge pull request #593 from acelaya-forks/feature/coding-standard-2.1
Feature/coding standard 2.1
2020-01-01 20:56:47 +01:00
Alejandro Celaya
a67cf4fb85 Updated changelog 2020-01-01 20:49:29 +01:00
Alejandro Celaya
50100c251e Updated to coding standard v2.1 2020-01-01 20:48:31 +01:00
Alejandro Celaya
1070482629 Merge pull request #591 from acelaya-forks/feature/upgrading-doc
Feature/upgrading doc
2020-01-01 11:31:58 +01:00
Alejandro Celaya
d205405dcc Updated DeprecatedConfigParser to remove the secret key 2020-01-01 11:27:09 +01:00
Alejandro Celaya
16d9c3b93f Updated changelog 2020-01-01 11:19:07 +01:00
Alejandro Celaya
52ecef0311 Created upgrade doc explaining how to upgrade from Shlinnk 1.x to 2.x 2020-01-01 11:17:44 +01:00
Alejandro Celaya
f172146f27 Merge pull request #590 from acelaya-forks/feature/remove-deprecations
Feature/remove deprecations
2019-12-31 23:51:27 +01:00
Alejandro Celaya
ee986912d4 Updated changelog 2019-12-31 23:44:42 +01:00
Alejandro Celaya
0e04968bc2 Changed latitude and longitude to float 2019-12-31 23:37:49 +01:00
Alejandro Celaya
0cf1d8d375 Changed validate_url to have default value of false 2019-12-31 16:30:59 +01:00
Alejandro Celaya
339121fbb1 Removed PathVersionMiddleware as routes without version are not longer supported 2019-12-31 16:26:00 +01:00
Alejandro Celaya
f99ca464de Removed old command aliases 2019-12-31 16:08:08 +01:00
Alejandro Celaya
5c90a7c7a7 Removed remaining deprecated elements 2019-12-31 16:05:02 +01:00
Alejandro Celaya
434b56fa8c Removed several deprecated components 2019-12-31 15:38:37 +01:00
Alejandro Celaya
78b484e657 Deleted everything related with previews generation 2019-12-31 13:40:38 +01:00
Alejandro Celaya
9d36534230 Merge pull request #589 from acelaya-forks/feature/problem-details-upgrade
Updated to problem-details 1.1, removing custom code
2019-12-30 22:48:24 +01:00
Alejandro Celaya
bd6243b2ac Updated to problem-details 1.1, removing custom code 2019-12-30 22:42:29 +01:00
Alejandro Celaya
416857e129 Updated changelog 2019-12-29 23:32:33 +01:00
Alejandro Celaya
8cd81d0441 Merge pull request #578 from acelaya-forks/feature/php-74-requirement
Feature/php 74 requirement
2019-12-29 23:29:42 +01:00
Alejandro Celaya
bf0d9ab7d9 Removed not needed null check 2019-12-29 23:19:00 +01:00
Alejandro Celaya
bfeb915cd2 Replaced regular callbacks by arrow functions when possible 2019-12-29 23:16:55 +01:00
Alejandro Celaya
a830420d75 Added property types to all non-deprecated classes 2019-12-29 22:48:40 +01:00
Alejandro Celaya
b904c6d00d Added property types to some classes 2019-12-29 22:27:00 +01:00
Alejandro Celaya
050050a9eb Updated base image for all docerfiles to use PHP 7.4.1 2019-12-29 16:34:43 +01:00
Alejandro Celaya
9e48dc4137 Updated more references to now unsupported PHP versions 2019-12-29 16:09:05 +01:00
Alejandro Celaya
2bd9bb233c Updated development assets and required PHP 7.4 2019-12-29 16:09:05 +01:00
Alejandro Celaya
e92d437456 Merge pull request #588 from shlinkio/develop
Develop to master
2019-12-29 15:55:01 +01:00
Alejandro Celaya
fd6151040e Merge pull request #587 from acelaya-forks/feature/visit-webhook
Feature/visit webhook
2019-12-29 14:36:40 +01:00
Alejandro Celaya
b4e3dd7b4e Updated changelog with v1.21.0 2019-12-29 14:15:50 +01:00
Alejandro Celaya
8667544b3a Updated to installer v3.3 2019-12-29 14:09:51 +01:00
Alejandro Celaya
664569a52b Added visits_webhooks option to SimplifiedConfigParser 2019-12-28 16:42:21 +01:00
Alejandro Celaya
3c9da80962 Documented how to provide visits webhooks to docker image via env vars 2019-12-28 16:35:16 +01:00
Alejandro Celaya
583985e7ce Moved VisitLocated as a regular event, since async tasks cannot trigger other async tasks 2019-12-28 13:50:41 +01:00
Alejandro Celaya
b17bcb6c93 Updated LocateShortUrlVisit so that it dispatches a VisitLocated event 2019-12-28 13:07:11 +01:00
Alejandro Celaya
4886825564 Improved NotifyVisitToWebHooksTest to kill more mutants 2019-12-28 10:43:13 +01:00
Alejandro Celaya
79cd3ba912 Created NotifyVisitToWebhooksTest 2019-12-27 20:32:21 +01:00
Alejandro Celaya
21a3d4b66b Updated NotifyVisitToWebHooks so that it waits for all requests to finish 2019-12-27 17:07:20 +01:00
Alejandro Celaya
562b0a0868 Used PSR3 logger preprocessor format instead of sprintf when possible 2019-12-27 16:15:14 +01:00
Alejandro Celaya
25243a10ec Moved common bootstrapping code to run.php script 2019-12-27 14:02:43 +01:00
Alejandro Celaya
3fdba53995 Added basic implementation for new webhook events 2019-12-27 13:37:59 +01:00
Alejandro Celaya
34d8b396a4 Fixed merge conflicts 2019-12-23 11:17:20 +01:00
Alejandro Celaya
c560e1fda2 Merge pull request #586 from acelaya-forks/hotfix/1.20.3
Hotfix/1.20.3
2019-12-23 11:06:29 +01:00
Alejandro Celaya
3634236214 Fixed some comments 2019-12-23 11:00:38 +01:00
Alejandro Celaya
6de0cba0b0 Updated changelog 2019-12-23 10:50:03 +01:00
Alejandro Celaya
35f5f4851e Moved class alias to container.php to avoid it from being lost after configuration is cached 2019-12-23 10:38:06 +01:00
Alejandro Celaya
3a8f4de3bb Merge pull request #584 from acelaya-forks/feature/guzzle-fix
Feature/guzzle fix
2019-12-21 16:38:34 +01:00
Alejandro Celaya
d67321f187 Removed workarounds from UrlValidator that were required for guzzle 6.5.0 2019-12-21 16:09:29 +01:00
Alejandro Celaya
7c52d0ec19 Required at least guzzle 6.5.1 2019-12-21 16:02:12 +01:00
Alejandro Celaya
ea08ab9758 Merge pull request #583 from acelaya-forks/feature/improve-docs
Updated documentation, adding more sub-sections and trying to explain…
2019-12-19 11:41:36 +01:00
Alejandro Celaya
9c06803a31 Updated documentation, adding more sub-sections and trying to explain everything even better 2019-12-19 11:39:41 +01:00
Alejandro Celaya
9222dcbc2e Merge pull request #581 from acelaya-forks/feature/improve-dockers
Feature/improve dockers
2019-12-18 15:38:03 +01:00
Alejandro Celaya
75b91dc26b Hardcoded different creation dates for fixture short URLs to avoid random API test failures 2019-12-18 15:26:23 +01:00
Alejandro Celaya
4334ea295d Added missing local config 2019-12-18 15:00:39 +01:00
Alejandro Celaya
03eeef7f52 Updated changelog 2019-12-18 14:55:37 +01:00
Alejandro Celaya
0747137679 Added php ini config for docker image 2019-12-18 14:54:48 +01:00
Alejandro Celaya
0152f6fa1a Added dev php config and removed .env dependencies 2019-12-17 21:20:24 +01:00
Alejandro Celaya
9f2ede0b84 Merge pull request #579 from acelaya-forks/feature/readme-logo
Feature/readme logo
2019-12-17 13:46:46 +01:00
Alejandro Celaya
748786d599 Updated project header image 2019-12-17 13:44:22 +01:00
Alejandro Celaya
18f0fb556a Added project logo to readme file 2019-12-17 13:40:08 +01:00
Alejandro Celaya
685b3f86b3 Merge pull request #572 from alesub/date-filters
Date filters for short urls list endpoint
2019-12-17 10:33:46 +01:00
Alejandro Celaya
524914fd35 Updated changelog 2019-12-17 10:14:18 +01:00
Alejandro Celaya
f7d09bf173 Slight refactoring on ListSHortUrlsCommand 2019-12-17 10:11:54 +01:00
Alejandro Celaya
4b113e5781 Added tests covering how orderBy is parsed on ListShortUrlsCommand 2019-12-17 10:06:54 +01:00
Alejandro Celaya
5616579131 Added startDate and endDate params to ListShortUrlsCommand 2019-12-17 09:59:54 +01:00
Alejandro Celaya
8142801f1f Updated ListShortUrlsAction api test so that it covers filtering use cases 2019-12-16 23:03:32 +01:00
Alejandro Celaya
35eeaf4282 Improved repository tests covering fetching and counting filtered short URL lists 2019-12-16 22:17:33 +01:00
Alejandro Celaya
8ad8b08aa4 Improved ListShortUrlsActionTest covering different scenarios in which date ranges are provided 2019-12-16 21:55:48 +01:00
Alejandro Celaya
839ca31821 Ensured date range filtering is also passed to the count function on ShortUrlRepository 2019-12-16 21:46:27 +01:00
Alejandro Celaya
03a92e5556 Fixed trailing method comma which is not compatible with PHP 7.2 2019-12-16 15:22:03 +01:00
Alejandro Celaya
99fd5f937e Fixed existing tests and coding styles 2019-12-16 15:16:18 +01:00
Alejandro Medina
d7ffcd903d Add date filter fields to short urls documentation 2019-12-14 18:42:02 -03:00
Alejandro Medina
a28e7987e6 fixup! Add date range filter to list urls endpoint parameters 2019-12-14 18:32:58 -03:00
Alejandro Medina
f17c46bbed Add date range filter to short url service 2019-12-14 15:10:09 -03:00
Alejandro Medina
27008505e5 Add date range filter to short url service interface 2019-12-14 15:03:39 -03:00
Alejandro Medina
f9ba322547 Add date range filter to list urls endpoint parameters 2019-12-14 13:55:03 -03:00
Alejandro Medina
661efcb51f Add date range filter to short url repository adapter 2019-12-14 12:01:56 -03:00
Alejandro Medina
5928f28699 Add date range filter to short url repository 2019-12-14 11:58:52 -03:00
Alejandro Medina
1183d65184 Add date range filter to short url repository interface 2019-12-14 11:58:08 -03:00
Alejandro Celaya
fd53e49508 Merge pull request #574 from shlinkio/feature/php-7.4-build
Replaced PHP 7.4 snapshot by regular 7.4
2019-12-14 11:47:10 +01:00
Alejandro Celaya
c484e32641 Replaced PHP 7.4 snapshot by regular 7.4 2019-12-14 10:57:29 +01:00
Alejandro Celaya
c1741c99be Merge pull request #571 from acelaya-forks/bugfix/docker-version
Bugfix/docker version
2019-12-09 18:31:08 +01:00
Alejandro Celaya
a03179743d Updated changelog 2019-12-09 18:18:03 +01:00
Alejandro Celaya
83b9160ab1 Updated docker image build script so that it sets shlink version to 'latest' when source branch is develop 2019-12-09 18:16:57 +01:00
Alejandro Celaya
83757ed390 Merge pull request #568 from acelaya-forks/feature/guzzle-update
Updated to guzzle 6.5 and removed custom code
2019-12-07 21:13:17 +01:00
Alejandro Celaya
843e943251 Updated to guzzle 6.5 and removed custom code 2019-12-07 21:01:14 +01:00
Alejandro Celaya
a0a1d3de72 Used stable docker tag on every docker run example 2019-12-07 09:31:46 +01:00
Alejandro Celaya
e5f262869c Improved tag conflict docs and tests 2019-12-06 23:40:54 +01:00
Alejandro Celaya
a070a68a57 Fixed merge conflicts 2019-12-06 23:34:50 +01:00
Alejandro Celaya
3479bbbb36 Merge pull request #567 from acelaya-forks/hotfix/v1.20.2
Hotfix/v1.20.2
2019-12-06 23:09:20 +01:00
Alejandro Celaya
e1a1a0652f Merge pull request #566 from acelaya-forks/bugfix/date-parsing
Bugfix/date parsing
2019-12-06 22:52:22 +01:00
Alejandro Celaya
3e9b775114 Fixed failing test 2019-12-06 22:45:15 +01:00
Alejandro Celaya
57c91aca3c Updated changelog with v1.20.2 2019-12-06 22:40:08 +01:00
Alejandro Celaya
05a64b8d9e Ensured dates parsing does not mask actual validation errors 2019-12-06 22:38:22 +01:00
Alejandro Celaya
30780f9c5f Merge pull request #565 from acelaya-forks/bugfix/control-rename-tag
Bugfix/control rename tag
2019-12-06 21:13:54 +01:00
Alejandro Celaya
3455df9214 Updated changelog 2019-12-06 21:06:47 +01:00
Alejandro Celaya
27aa8f9875 Handled rename tag error from command 2019-12-06 21:04:52 +01:00
Alejandro Celaya
05451e3d1a Handled tag conflict from rename tag action 2019-12-06 21:03:27 +01:00
Alejandro Celaya
b9b3295b52 Ensured a specific exception is thrown from TagService when trying to rename a tag to the name of another tag which already exists 2019-12-06 20:44:41 +01:00
Alejandro Celaya
f62ed66e26 Created TagConflictException 2019-12-06 10:20:56 +01:00
Alejandro Celaya
e2a9a989ab Merge pull request #563 from acelaya-forks/bugfix/missing-yaml
Bugfix/missing yaml
2019-12-06 09:59:09 +01:00
Alejandro Celaya
4af27650cd Updated changelog 2019-12-06 09:52:23 +01:00
Alejandro Celaya
76a603104d Migrated migrations config file from yaml to plain PHP 2019-12-06 09:50:37 +01:00
Alejandro Celaya
03825469ca Merge pull request #559 from acelaya-forks/feature/msi-80
Feature/msi 80
2019-12-01 12:42:57 +01:00
Alejandro Celaya
058cdf7a82 Enforced a min msi of 80% 2019-12-01 12:34:26 +01:00
Alejandro Celaya
7f43890713 Improved CreateShortUrlAction test so that it cover more mutants 2019-12-01 12:26:31 +01:00
Alejandro Celaya
57070ef155 Improved Rest's ConfigProvider test to kill more mutants 2019-12-01 12:04:31 +01:00
Alejandro Celaya
fc5904e743 Improved BodyParserMiddlewareTest to kill more mutants 2019-12-01 10:58:48 +01:00
Alejandro Celaya
46c0620236 More test improvements trying to increase mutation score 2019-12-01 10:47:56 +01:00
Alejandro Celaya
1bf56b658b Improved domain exception tests to cover more possible mutants 2019-12-01 10:24:42 +01:00
Alejandro Celaya
8cc4d3e6d5 Merge pull request #558 from acelaya-forks/feature/monolog2
Feature/monolog2
2019-11-30 18:22:44 +01:00
Alejandro Celaya
3080c49caf Bringing back allowing failures on PHP 7.4 2019-11-30 18:15:09 +01:00
Alejandro Celaya
ed94ec39c4 Updated changelog 2019-11-30 18:09:38 +01:00
Alejandro Celaya
6bcdd5e6c8 Cleaned last beats of to make everything BC 2019-11-30 18:08:30 +01:00
Alejandro Celaya
cf3d763731 Replaced monolog-cascade by MonologFactory 2019-11-30 17:59:04 +01:00
Alejandro Celaya
e558bb17cb Updated dependencies 2019-11-30 17:21:36 +01:00
Alejandro Celaya
5d76a55c46 Updated how monolog handlers are registered so that it is possible to overwrite them via local config 2019-11-30 09:28:30 +01:00
Alejandro Celaya
4401824716 Updated changelog 2019-11-29 19:43:34 +01:00
Alejandro Celaya
df23f20d31 Merge pull request #554 from acelaya-forks/feature/problem-details
Feature/problem details
2019-11-29 19:38:08 +01:00
Alejandro Celaya
6c37905c15 Fixed cross-domain headers being lost when ProblemDetailsMiddleware throws an error 2019-11-29 19:24:04 +01:00
Alejandro Celaya
4685572def Added version param to endpoints 2019-11-29 19:09:03 +01:00
Alejandro Celaya
3cf1657d54 Simplified invalidElements to be a plain list of keys when a ValidationException is cast into a problem details error 2019-11-29 18:55:27 +01:00
Alejandro Celaya
60d3c09da5 Updated API docs to reference the use of application/problem+json 2019-11-28 19:37:31 +01:00
Alejandro Celaya
5055ddf995 Updated CLI commands to just print exception messages when possible 2019-11-28 18:47:34 +01:00
Alejandro Celaya
d83d2f82bd Added more strict checks on API errors tests 2019-11-27 20:48:35 +01:00
Alejandro Celaya
5266743a0c Added as much additional data as possible to exceptions 2019-11-27 20:18:36 +01:00
Alejandro Celaya
fffb2872ef Replaced hardcoded error response by the use of a problem details action 2019-11-26 22:18:55 +01:00
Alejandro Celaya
3b56fc3760 Refactored and fixed unit tests 2019-11-26 22:12:52 +01:00
Alejandro Celaya
5213faa0a1 Converted VerifyAuthenticationException into a problem details exception 2019-11-26 22:03:40 +01:00
Alejandro Celaya
6f4e5175da Converted MissingAuthenticationException into a problem details exception 2019-11-26 21:43:29 +01:00
Alejandro Celaya
f502eb0195 Added new test for the case in which an invalid URL is provided 2019-11-26 21:33:22 +01:00
Alejandro Celaya
509c9fe2e8 Improved AuthenticationMiddleware API tests 2019-11-26 21:29:25 +01:00
Alejandro Celaya
13e795d25d Updated ValidationException's base exception 2019-11-26 20:58:38 +01:00
Alejandro Celaya
a28ef1f176 Converted EntityDoesNotExistException into a problem details exception renamed as TagNotFoundException 2019-11-25 19:15:46 +01:00
Alejandro Celaya
0c5eec7e95 Replaced the use of EntityDoesNotExistException by ShorturlNotFoundException where applicable 2019-11-25 18:54:25 +01:00
Alejandro Celaya
310032e303 Converted DeleteShortUrlException into a problem details exception 2019-11-24 23:56:02 +01:00
Alejandro Celaya
32b3c72bdf Converted ValidationException into a problem details exception 2019-11-24 23:45:40 +01:00
Alejandro Celaya
c1eee2246b Converted NonUniqueSlugException into a problem details exception 2019-11-24 23:32:37 +01:00
Alejandro Celaya
0d7d53ab5b Converted InvalidUrlException into a problem details exception 2019-11-24 23:24:53 +01:00
Alejandro Celaya
2f1de4a162 Renamed InvalidShortCodeException to ShortCodeNotFoundException 2019-11-24 23:15:55 +01:00
Alejandro Celaya
cdd36b6712 Created BackwardsCompatibleProblemDetailsMiddlewareTest 2019-11-24 13:24:52 +01:00
Alejandro Celaya
6f0afe269d Moved InvalidShortCode exception handling to problem details 2019-11-24 12:41:12 +01:00
Alejandro Celaya
09321eaa93 Updated InvalidShortCodeException to implement ProblemDetails 2019-11-23 13:41:07 +01:00
Alejandro Celaya
850259290a Covered new use case on NotFoundRedirectHandlerTest 2019-11-23 10:28:58 +01:00
Alejandro Celaya
1bafe54a75 Split NotFoundHandler into two different middlewares 2019-11-23 10:25:12 +01:00
Alejandro Celaya
89e373f775 Moved NotFoundHandler to ErrorHandler namespace 2019-11-23 10:11:34 +01:00
Alejandro Celaya
74854b3dac Added zend problem details to the project 2019-11-22 19:49:14 +01:00
Alejandro Celaya
4e5ab21a47 Removed whoops dev dependency 2019-11-22 18:03:11 +01:00
Alejandro Celaya
a0510d6a69 Removed content-based-error-handler in preparation for the problem details module 2019-11-22 18:01:38 +01:00
Alejandro Celaya
6ddb60d047 Improved ValidationException to avoid polluting the message with invalid data but keeping it on the string representation 2019-11-21 20:07:57 +01:00
Alejandro Celaya
ad592a563c Updated testing utils library 2019-11-21 19:22:04 +01:00
Alejandro Celaya
b3b67b051d Created API tests for errors when updating tags 2019-11-21 19:03:34 +01:00
Alejandro Celaya
8607d58e18 Created API tests for errors when editting short URL tags 2019-11-21 18:49:55 +01:00
Alejandro Celaya
34e60ec5b8 Created API tests for errors when getting short URL visits 2019-11-20 20:58:16 +01:00
Alejandro Celaya
d044e1a5b7 Created API tests for errors when resolving short URLs 2019-11-20 20:44:03 +01:00
Alejandro Celaya
9096318968 Created API tests for errors when deleting short URLs 2019-11-20 20:38:19 +01:00
Alejandro Celaya
ba6e8c4092 Created API tests for errors when editing a short URL 2019-11-20 20:31:18 +01:00
Alejandro Celaya
98b6dba05d Removed generic error handling from action that will usually be handled by ErrorHandler middleware 2019-11-20 20:21:02 +01:00
Alejandro Celaya
84c4631124 Deleted specific factory by replacing it by ConfigAbstractFactory 2019-11-20 20:18:21 +01:00
Alejandro Celaya
a7d308c585 Merge pull request #553 from acelaya-forks/feature/doctrine-2.7
Updated to latest doctrine versions, solving deprecations
2019-11-20 20:12:02 +01:00
Alejandro Celaya
af0ed6135e Updated to latest doctrine versions, solving deprecations 2019-11-20 20:03:06 +01:00
Alejandro Celaya
115ca0da0f Added v1.20.1 to changelog 2019-11-17 11:29:54 +01:00
Alejandro Celaya
673b545a83 Merge pull request #551 from acelaya-forks/feature/non-shared-locker
Feature/non shared locker
2019-11-17 11:21:27 +01:00
Alejandro Celaya
d030fd1aa6 Updated GeolocationDbUpdater to always use a local lock even if redis config is provided 2019-11-17 11:09:37 +01:00
Alejandro Celaya
7c1e40be88 Updated docker docs regarding image versioning 2019-11-17 10:38:05 +01:00
Alejandro Celaya
b739619532 Merge pull request #550 from acelaya-forks/feature/fix-db-silent-errors
Feature/fix db silent errors
2019-11-17 10:08:57 +01:00
Alejandro Celaya
372b83d92f Updated changelog 2019-11-17 10:02:03 +01:00
Alejandro Celaya
4e3b5419d5 Created small helper composer command 2019-11-17 10:00:29 +01:00
Alejandro Celaya
c34d5a35e2 Updated database commands so that internal commands are run with mustRun 2019-11-17 09:52:45 +01:00
Alejandro Celaya
a959b5bf02 Merge pull request #549 from acelaya-forks/feature/use-own-test-domains
Replaced third party domains used in tests by custom shlink domains
2019-11-16 13:47:37 +01:00
Alejandro Celaya
45ac2c3c51 Replaced third party domains used in tests by custom shlink domains 2019-11-16 13:37:53 +01:00
Alejandro Celaya
f6bddc6f24 Merge pull request #548 from acelaya-forks/feature/redirect-to-idn
Handled IDN domains also on internal redirections when validating a URL
2019-11-16 12:46:02 +01:00
Alejandro Celaya
6b8fc3228e Handled IDN domains also on internal redirections when validating a URL 2019-11-16 12:38:45 +01:00
Alejandro Celaya
8cf1a95df5 Swoole is no longer experimental 2019-11-16 10:59:56 +01:00
Alejandro Celaya
b3ea2969c5 Merge pull request #547 from acelaya-forks/feature/support-idn
Feature/support idn
2019-11-16 10:32:49 +01:00
Alejandro Celaya
054bbb8d5a Updated changelog 2019-11-16 10:22:00 +01:00
Alejandro Celaya
19c1b29f59 Added tests for UrlValidator 2019-11-16 10:19:25 +01:00
Alejandro Celaya
264b8c2a9e Added support for IDN 2019-11-16 10:06:55 +01:00
Alejandro Celaya
ec33b95f97 Brought intl extension back to docker images and kept as a requirement 2019-11-16 09:46:42 +01:00
Alejandro Celaya
4437d5305f Merge pull request #546 from acelaya-forks/feature/image-version
Feature/image version
2019-11-15 22:24:42 +01:00
Alejandro Celaya
f20f01e22e Removed Intl from docker image 2019-11-15 22:23:07 +01:00
Alejandro Celaya
1ee30fe5dc Updated dev docker images 2019-11-15 22:05:34 +01:00
Alejandro Celaya
4dc026d7fc Merge pull request #544 from Starbix/master
Update dependencies and baseimage
2019-11-15 22:01:14 +01:00
Cédric Laubacher
1e862a8ee8 Readd specific alpine version 2019-11-15 21:42:07 +01:00
Alejandro Celaya
5ece2d1939 Merge pull request #539 from acelaya-forks/feature/forward-query
Feature/forward query
2019-11-15 20:43:11 +01:00
Alejandro Celaya
146e9100be Updated changelog 2019-11-15 20:30:36 +01:00
Cédric Laubacher
0c854edc6b Use specific PHP version 2019-11-15 19:16:29 +01:00
Cédric Laubacher
07d031e7b9 Update Dockerfile 2019-11-15 17:55:06 +01:00
Alejandro Celaya
705dc2ec39 Added forward of query string from short URLs to long one 2019-11-13 21:04:44 +01:00
Alejandro Celaya
3b9221c7d2 Ensured options for short.url:list command have required values 2019-11-13 20:24:59 +01:00
Alejandro Celaya
576d602ed0 Merge pull request #537 from acelaya-forks/feature/installer-3.1
Updated to installer 3.1
2019-11-10 13:15:30 +01:00
Alejandro Celaya
9df8bd63d4 Updated to installer 3.1 2019-11-10 13:07:57 +01:00
Alejandro Celaya
99c4802367 Fixed docker docs line break 2019-11-10 12:14:00 +01:00
Alejandro Celaya
94dc6f2053 Merge pull request #536 from acelaya-forks/feature/simplified-config-workers
Added workers nums handling to simplified config parser
2019-11-10 12:11:41 +01:00
Alejandro Celaya
d4005da35c Added workers nums handling to simplified config parser 2019-11-10 12:04:14 +01:00
Alejandro Celaya
cbe2c362d5 Merge pull request #535 from acelaya-forks/feature/api-test-script
Updated API tests script so that it throws the same exit code returne…
2019-11-09 12:15:09 +01:00
Alejandro Celaya
8bf79db66a Fixed typo 2019-11-09 12:08:22 +01:00
Alejandro Celaya
b87964f716 Updated API tests script so that it throws the same exit code returned by phpunit 2019-11-09 11:25:33 +01:00
Alejandro Celaya
b0a574f578 Merge pull request #533 from acelaya-forks/feature/custom-workers
Feature/custom workers
2019-11-09 11:17:03 +01:00
Alejandro Celaya
92dc3019de Updated changelog 2019-11-09 11:08:28 +01:00
Alejandro Celaya
d8f92cb2be Added web worker num and task worker num to docker image config 2019-11-09 11:05:54 +01:00
Alejandro Celaya
bf24660ddb Merge pull request #526 from acelaya-forks/feature/enhanced-not-found-redirect
Feature/enhanced not found redirect
2019-11-02 21:24:34 +01:00
Alejandro Celaya
b66268867a Updated to shlink-installer 3 2019-11-02 21:15:26 +01:00
Alejandro Celaya
9abaa243e0 Some extra minor improvements 2019-11-02 19:08:07 +01:00
Alejandro Celaya
7030138ff4 Updated changelog 2019-11-02 18:57:16 +01:00
Alejandro Celaya
906dfe60f8 Simplified code to render not-foubnd templates by infering the template to be used inside NotFoundHandler 2019-11-02 18:49:24 +01:00
Alejandro Celaya
01f60614ef Removed hardcoded route names for core routes and used action class names instead 2019-11-02 18:36:15 +01:00
Alejandro Celaya
eeb5306883 Moved all logic to redirect to specific URLs when a 404 is found to the NotFoundHandler 2019-11-02 18:33:26 +01:00
Alejandro Celaya
24c3a3e84c Defined new options for new redirect configuration 2019-11-02 17:23:21 +01:00
Alejandro Celaya
8b9663aea0 Created DeprecatedConfigParserTest 2019-11-02 17:04:49 +01:00
Alejandro Celaya
b59f4e2805 Defined new configs for not found redirects 2019-11-02 11:30:09 +01:00
Alejandro Celaya
6293d57fde Merge pull request #523 from acelaya-forks/feature/refactorings
Feature/refactorings
2019-11-01 17:31:43 +01:00
Alejandro Celaya
39ac2efe26 Updated to latest shlink-common with bug fixes 2019-11-01 17:16:56 +01:00
Alejandro Celaya
1f449e8ce1 Disabled coroutines on swoole during API tests 2019-11-01 10:10:43 +01:00
Alejandro Celaya
ad906000c7 Removed typehint making phpstan throw false positive 2019-11-01 10:04:25 +01:00
Alejandro Celaya
5361f33cc1 Some more refactorings 2019-11-01 09:52:56 +01:00
Alejandro Celaya
1937f3ea22 Trying to automatically persist tags 2019-10-26 09:01:51 +02:00
Alejandro Celaya
f4e9d0c8fe Merge pull request #517 from acelaya-forks/feature/too-long-lock
Updated to shlink-ip-geolocation v1.1
2019-10-25 20:12:54 +02:00
Alejandro Celaya
9b767ee9f3 Updated to shlink-ip-geolocation v1.1 2019-10-25 20:00:26 +02:00
Alejandro Celaya
43cb91bf52 Merge pull request #516 from acelaya-forks/feature/qr-code-with-domain
Feature/qr code with domain
2019-10-22 20:03:37 +02:00
Alejandro Celaya
f784ee5b28 Fixed unit tests 2019-10-22 19:52:28 +02:00
Alejandro Celaya
cd6f067fe5 Ensured domain is taken into account when generating QR codes 2019-10-22 19:43:53 +02:00
Alejandro Celaya
6d366188c9 Added github funding 2019-10-22 19:37:35 +02:00
Alejandro Celaya
c4ca59dcb0 Merge pull request #515 from acelaya-forks/feature/host-and-port
Feature/host and port
2019-10-20 11:14:44 +02:00
Alejandro Celaya
74675ad314 Updated changelog 2019-10-20 10:30:51 +02:00
Alejandro Celaya
b5e4da847a Allowed port number on domain field when creating shotr URLs 2019-10-20 10:30:11 +02:00
Alejandro Celaya
232bf5a68b Merge pull request #513 from acelaya-forks/feature/fix-long-urls
Feature/fix long urls
2019-10-20 10:15:38 +02:00
Alejandro Celaya
67958a78d3 Updated changelog 2019-10-20 09:55:00 +02:00
Alejandro Celaya
b8cdc29d8f Increased long URL size in DB to 2048 characters 2019-10-20 09:53:11 +02:00
Alejandro Celaya
30e4ddb950 Updated to latest infection version 2019-10-20 09:42:46 +02:00
Alejandro Celaya
a61a7db275 Merge pull request #510 from acelaya-forks/feature/update-common
Updated common and qr-code
2019-10-15 19:17:44 +02:00
Alejandro Celaya
0f5e4e7fa2 Updated common and qr-code 2019-10-15 19:06:37 +02:00
Alejandro Celaya
eb17eae781 Merge pull request #506 from acelaya-forks/feature/improved-shortcodes
Feature/improved shortcodes
2019-10-11 12:51:24 +02:00
Alejandro Celaya
740a65f880 Updated references to SHORTCODE_CHARS in docker docs 2019-10-11 11:41:14 +02:00
Alejandro Celaya
5bd7b53e0a Added more tests for new logics 2019-10-11 11:28:53 +02:00
Alejandro Celaya
9538f474de Added logic to check if a short code is in use and regenerate it otherwise 2019-10-11 11:09:33 +02:00
Alejandro Celaya
8f2e78c946 Moved logic to generate random short codes to external function 2019-10-11 09:35:09 +02:00
Alejandro Celaya
2f09ff456c Updated logic to generate random short codes, increasing entropy 2019-10-11 09:14:25 +02:00
Alejandro Celaya
c8d950e04d Merge pull request #504 from acelaya-forks/feature/mariadb
Feature/mariadb
2019-10-06 12:37:22 +02:00
Alejandro Celaya
0f6a0da7a4 Added MariaDB to documentation 2019-10-06 12:27:11 +02:00
Alejandro Celaya
4300fb225f Ensured tests on maria DB are not run on travis, since it would conflict with MySQL 2019-10-06 12:23:02 +02:00
Alejandro Celaya
159021e87c Added MariaDB to issue templates 2019-10-06 11:39:53 +02:00
Alejandro Celaya
9dc6ea9eeb Documented how to use maria db with docker image 2019-10-06 11:38:23 +02:00
Alejandro Celaya
42e84e526e Added mariadb container for development environment 2019-10-06 11:21:41 +02:00
Alejandro Celaya
700ee40109 Merge pull request #503 from acelaya-forks/feature/update-coding-standard
Feature/update coding standard
2019-10-05 18:07:12 +02:00
Alejandro Celaya
4909bd9550 Updated changelog 2019-10-05 17:29:07 +02:00
Alejandro Celaya
e0d20bf8ff Updated to coding styles v2 2019-10-05 17:26:10 +02:00
479 changed files with 11762 additions and 7913 deletions

View File

@@ -8,17 +8,16 @@ data/migrations_template.txt
data/GeoLite2-City.*
data/database.sqlite
data/shlink-tests.db
**/.gitignore
CHANGELOG.md
UPGRADE.md
composer.lock
vendor
docs
indocker
docker-*
php*
infection.json
phpstan.neon
php*xml*
infection.json
**/test*
build*
.github
hooks
**/.*

View File

@@ -1,11 +0,0 @@
# Application
APP_ENV=
SECRET_KEY=
SHORTENED_URL_SCHEMA=
SHORTENED_URL_HOSTNAME=
SHORTCODE_CHARS=
# Database
DB_USER=
DB_PASSWORD=
DB_NAME=

3
.gitattributes vendored
View File

@@ -5,11 +5,8 @@
/module/CLI/test-resources export-ignore
/module/Core/test export-ignore
/module/Core/test-db export-ignore
/module/PreviewGenerator/test export-ignore
/module/PreviewGenerator/test-db export-ignore
/module/Rest/test export-ignore
/module/Rest/test-api export-ignore
.env.dist export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.phpstorm.meta.php export-ignore

1
.github/FUNDING.yml vendored
View File

@@ -1 +1,2 @@
github: ['acelaya']
custom: ['https://acel.me/donate']

View File

@@ -18,7 +18,7 @@ With that said, please fill in the information requested next. More information
* Shlink Version: x.y.z
* PHP Version: x.y.z
* How do you serve Shlink: Self-hosted Apache|Self-hosted nginx|Self-hosted swoole|Docker image
* Database engine used: MySQL|PostgreSQL|SQLite (x.y.z)
* Database engine used: MySQL|MariaDB|PostgreSQL|MicrosoftSQL|SQLite (x.y.z)
#### Summary

View File

@@ -18,7 +18,7 @@ With that said, please fill in the information requested next. More information
* Shlink Version: x.y.z
* PHP Version: x.y.z
* How do you serve Shlink: Self-hosted Apache|Self-hosted nginx|Self-hosted swoole|Docker image
* Database engine used: MySQL|PostgreSQL|SQLite (x.y.z)
* Database engine used: MySQL|MariaDB|PostgreSQL|MicrosoftSQL|SQLite (x.y.z)
#### Summary

3
.gitignore vendored
View File

@@ -1,10 +1,9 @@
.idea
build
!hooks/build
!docker/build
composer.lock
composer.phar
vendor/
.env
data/database.sqlite
data/shlink-tests.db
data/GeoLite2-City.mmdb

View File

@@ -2,7 +2,7 @@
namespace PHPSTORM_META;
use Psr\Container\ContainerInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
/**
* PhpStorm Container Interop code completion

View File

@@ -6,6 +6,9 @@ checks:
code_rating: true
duplication: true
build:
dependencies:
override:
- composer install --no-interaction --no-scripts --ignore-platform-reqs
nodes:
analysis:
tests:

View File

@@ -5,48 +5,46 @@ branches:
- /.*/
php:
- '7.2'
- '7.3'
- '7.4snapshot'
matrix:
allow_failures:
- php: '7.4snapshot'
- '7.4'
services:
- mysql
- postgresql
- docker
cache:
directories:
- $HOME/.composer/cache/files
before_install:
- sudo ./data/infra/ci/install-ms-odbc.sh
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml up -d shlink_db_ms shlink_db shlink_db_postgres shlink_db_maria
- yes | pecl install pdo_sqlsrv swoole-4.4.18
- echo 'extension = apcu.so' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- yes | pecl install swoole
- phpenv config-rm xdebug.ini || return 0
install:
- composer self-update
- composer install --no-interaction
- composer install --no-interaction --prefer-dist
before_script:
- mysql -e 'CREATE DATABASE shlink_test;'
- psql -c 'create database shlink_test;' -U postgres
- docker-compose exec shlink_db_ms /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 'Passw0rd!' -Q "CREATE DATABASE shlink_test;"
- mkdir build
- export DOCKERFILE_CHANGED=$(git diff ${TRAVIS_COMMIT_RANGE:-origin/master} --name-only | grep Dockerfile)
script:
- composer ci
- if [[ ! -z "$DOCKERFILE_CHANGED" && "${TRAVIS_PHP_VERSION}" == "7.2" ]]; then docker build -t shlink-docker-image:temp . ; fi
- if [[ ! -z "$DOCKERFILE_CHANGED" && "${TRAVIS_PHP_VERSION}" == "7.4" ]]; then docker build -t shlink-docker-image:temp . ; fi
after_success:
- rm -f build/clover.xml
- phpdbg -qrr vendor/bin/phpcov merge build --clover build/clover.xml
- wget https://phar.phpunit.de/phpcov-7.0.2.phar
- phpdbg -qrr phpcov-7.0.2.phar merge build --clover build/clover.xml
- wget https://scrutinizer-ci.com/ocular.phar
- php ocular.phar code-coverage:upload --format=php-clover build/clover.xml
# Before deploying, build dist file for current travis tag
before_deploy:
- rm -f ocular.phar
- ./build.sh ${TRAVIS_TAG#?}
- if [[ ! -z $TRAVIS_TAG && "${TRAVIS_PHP_VERSION}" == "7.4" ]]; then ./build.sh ${TRAVIS_TAG#?} ; fi
deploy:
- provider: releases
@@ -56,4 +54,10 @@ deploy:
skip_cleanup: true
on:
tags: true
php: '7.2'
php: '7.4'
- provider: script
script: bash ./docker/build
on:
all_branches: true
condition: $TRAVIS_PULL_REQUEST == 'false'
php: '7.4'

View File

@@ -4,6 +4,558 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com), and this project adheres to [Semantic Versioning](https://semver.org).
## 2.2.1 - 2020-05-11
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#764](https://github.com/shlinkio/shlink/issues/764) Fixed error when trying to match an existing short URL which does not have `validSince` and/or `validUntil`, but you are providing either one of them for the new one.
## 2.2.0 - 2020-05-09
#### Added
* [#712](https://github.com/shlinkio/shlink/issues/712) Added support to integrate Shlink with a [mercure hub](https://mercure.rocks/) server.
Thanks to that, Shlink will be able to publish events that can be consumed in real time.
For now, two topics (events) are published, when new visits occur. Both include a payload with the visit and the shortUrl:
* A visit occurs on any short URL: `https://shlink.io/new-visit`.
* A visit occurs on short URLs with a specific short code: `https://shlink.io/new-visit/{shortCode}`.
The updates are only published when serving Shlink with swoole.
Also, Shlink exposes a new endpoint `GET /rest/v2/mercure-info`, which returns the public URL of the mercure hub, and a valid JWT that can be used to subscribe to updates.
* [#673](https://github.com/shlinkio/shlink/issues/673) Added new `[GET /visits]` rest endpoint which returns basic visits stats.
* [#674](https://github.com/shlinkio/shlink/issues/674) Added new `[GET /tags/{tag}/visits]` rest endpoint which returns visits by tag.
It works in the same way as the `[GET /short-urls/{shortCode}/visits]` one, returning the same response payload, and supporting the same query params, but the response is the list of visits in all short URLs which have provided tag.
* [#672](https://github.com/shlinkio/shlink/issues/672) Enhanced `[GET /tags]` rest endpoint so that it is possible to get basic stats info for every tag.
Now, if the `withStats=true` query param is provided, the response payload will include a new `stats` property which is a list with the amount of short URLs and visits for every tag.
Also, the `tag:list` CLI command has been changed and it always behaves like this.
* [#640](https://github.com/shlinkio/shlink/issues/640) Allowed to optionally disable visitors' IP address anonymization. This will make Shlink no longer be GDPR-compliant, but it's OK if you only plan to share your URLs in countries without this regulation.
#### Changed
* [#692](https://github.com/shlinkio/shlink/issues/692) Drastically improved performance when loading visits. Specially noticeable when loading big result sets.
* [#657](https://github.com/shlinkio/shlink/issues/657) Updated how DB tests are run in travis by using docker containers which allow all engines to be covered.
* [#751](https://github.com/shlinkio/shlink/issues/751) Updated PHP and swoole versions used in docker image, and removed mssql-tools, as they are not needed.
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#729](https://github.com/shlinkio/shlink/issues/729) Fixed weird error when fetching multiple visits result sets concurrently using mariadb or mysql.
* [#735](https://github.com/shlinkio/shlink/issues/735) Fixed error when cleaning metadata cache during installation when APCu is enabled.
* [#677](https://github.com/shlinkio/shlink/issues/677) Fixed `/health` endpoint returning `503` fail responses when the database connection has expired.
* [#732](https://github.com/shlinkio/shlink/issues/732) Fixed wrong client IP in access logs when serving app with swoole behind load balancer.
## 2.1.4 - 2020-04-30
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#742](https://github.com/shlinkio/shlink/issues/742) Allowed a custom GeoLite2 license key to be provided, in order to avoid download limits.
## 2.1.3 - 2020-04-09
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#712](https://github.com/shlinkio/shlink/issues/712) Fixed app set-up not clearing entities metadata cache.
* [#711](https://github.com/shlinkio/shlink/issues/711) Fixed `HEAD` requests returning a duplicated `Content-Length` header.
* [#716](https://github.com/shlinkio/shlink/issues/716) Fixed Twitter not properly displaying preview for final long URL.
* [#717](https://github.com/shlinkio/shlink/issues/717) Fixed DB connection expiring on task workers when using swoole.
* [#705](https://github.com/shlinkio/shlink/issues/705) Fixed how the short URL domain is inferred when generating QR codes, making sure the configured domain is respected even if the request is performed using a different one, and only when a custom domain is used, then that one is used instead.
## 2.1.2 - 2020-03-29
#### Added
* *Nothing*
#### Changed
* [#696](https://github.com/shlinkio/shlink/issues/696) Updated to infection v0.16.
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#700](https://github.com/shlinkio/shlink/issues/700) Fixed migration not working with postgres.
* [#690](https://github.com/shlinkio/shlink/issues/690) Fixed tags being incorrectly sluggified when filtering short URL lists, making results not be the expected.
## 2.1.1 - 2020-03-28
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#697](https://github.com/shlinkio/shlink/issues/697) Recovered `.htaccess` file that was unintentionally removed in v2.1.0, making Shlink unusable with Apache.
## 2.1.0 - 2020-03-28
#### Added
* [#626](https://github.com/shlinkio/shlink/issues/626) Added support for Microsoft SQL Server.
* [#556](https://github.com/shlinkio/shlink/issues/556) Short code lengths can now be customized, both globally and on a per-short URL basis.
* [#541](https://github.com/shlinkio/shlink/issues/541) Added a request ID that is returned on `X-Request-Id` header, can be provided from outside and is set in log entries.
* [#642](https://github.com/shlinkio/shlink/issues/642) IP geolocation is now performed over the non-anonymized IP address when using swoole.
* [#521](https://github.com/shlinkio/shlink/issues/521) The long URL for any existing short URL can now be edited using the `PATCH /short-urls/{shortCode}` endpoint.
#### Changed
* [#656](https://github.com/shlinkio/shlink/issues/656) Updated to PHPUnit 9.
* [#641](https://github.com/shlinkio/shlink/issues/641) Added two new flags to the `visit:locate` command, `--retry` and `--all`.
* When `--retry` is provided, it will try to re-locate visits which IP address was originally considered not found, in case it was a temporal issue.
* When `--all` is provided together with `--retry`, it will try to re-locate all existing visits. A warning and confirmation are displayed, as this can have side effects.
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#665](https://github.com/shlinkio/shlink/issues/665) Fixed `base_url_redirect_to` simplified config option not being properly parsed.
* [#663](https://github.com/shlinkio/shlink/issues/663) Fixed Shlink allowing short URLs to be created with an empty custom slug.
* [#678](https://github.com/shlinkio/shlink/issues/678) Fixed `db` commands not running in a non-interactive way.
## 2.0.5 - 2020-02-09
#### Added
* [#651](https://github.com/shlinkio/shlink/issues/651) Documented how Shlink behaves when using multiple domains.
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#648](https://github.com/shlinkio/shlink/issues/648) Ensured any user can write in log files, in case shlink is run by several system users.
* [#650](https://github.com/shlinkio/shlink/issues/650) Ensured default domain is ignored when trying to create a short URL.
## 2.0.4 - 2020-02-02
#### Added
* *Nothing*
#### Changed
* [#577](https://github.com/shlinkio/shlink/issues/577) Wrapped params used to customize short URL lists into a DTO with implicit validation.
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#620](https://github.com/shlinkio/shlink/issues/620) Ensured "controlled" errors (like validation errors and such) won't be logged with error level, preventing logs to be polluted.
* [#637](https://github.com/shlinkio/shlink/issues/637) Fixed several work flows in which short URLs with domain are handled form the API.
* [#644](https://github.com/shlinkio/shlink/issues/644) Fixed visits to short URL on non-default domain being linked to the URL on default domain with the same short code.
* [#643](https://github.com/shlinkio/shlink/issues/643) Fixed searching on short URL lists not taking into consideration the domain name.
## 2.0.3 - 2020-01-27
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#624](https://github.com/shlinkio/shlink/issues/624) Fixed order in which headers for remote IP detection are inspected.
* [#623](https://github.com/shlinkio/shlink/issues/623) Fixed short URLs metadata being impossible to reset.
* [#628](https://github.com/shlinkio/shlink/issues/628) Fixed `GET /short-urls/{shortCode}` REST endpoint returning a 404 for short URLs which are not enabled.
* [#621](https://github.com/shlinkio/shlink/issues/621) Fixed permission denied error when updating same GeoLite file version more than once.
## 2.0.2 - 2020-01-12
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#614](https://github.com/shlinkio/shlink/issues/614) Fixed `OPTIONS` requests including the `Origin` header not always returning an empty body with status 2xx.
* [#615](https://github.com/shlinkio/shlink/issues/615) Fixed query args with no value being lost from the long URL when users are redirected.
## 2.0.1 - 2020-01-10
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#607](https://github.com/shlinkio/shlink/issues/607) Added missing info on UPGRADE.md doc.
* [#610](https://github.com/shlinkio/shlink/issues/610) Fixed use of hardcoded quotes on a database migration which makes it fail on postgres.
* [#605](https://github.com/shlinkio/shlink/issues/605) Fixed crashes occurring when migrating from old Shlink versions with nullable DB columns that are assigned to non-nullable entity typed props.
## 2.0.0 - 2020-01-08
#### Added
* [#429](https://github.com/shlinkio/shlink/issues/429) Added support for PHP 7.4
* [#529](https://github.com/shlinkio/shlink/issues/529) Created an UPGRADING.md file explaining how to upgrade from v1.x to v2.x
* [#594](https://github.com/shlinkio/shlink/issues/594) Updated external shlink packages, including installer v4.0, which adds the option to ask for the redis cluster config.
#### Changed
* [#592](https://github.com/shlinkio/shlink/issues/592) Updated coding styles to use [shlinkio/php-coding-standard](https://github.com/shlinkio/php-coding-standard) v2.1.0.
* [#530](https://github.com/shlinkio/shlink/issues/530) Migrated project from deprecated `zendframework` components to the new `laminas` and `mezzio` ones.
#### Deprecated
* *Nothing*
#### Removed
* [#429](https://github.com/shlinkio/shlink/issues/429) Dropped support for PHP 7.2 and 7.3
* [#229](https://github.com/shlinkio/shlink/issues/229) Remove everything which was deprecated, including:
* Preview generation feature completely removed.
* Authentication against REST API using JWT is no longer supported.
See [UPGRADE](UPGRADE.md) doc in order to get details on how to migrate to this version.
#### Fixed
* [#600](https://github.com/shlinkio/shlink/issues/600) Fixed health action so that it works with and without version in the path.
## 1.21.1 - 2020-01-02
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#596](https://github.com/shlinkio/shlink/issues/596) Fixed error when trying to download GeoLite2 database due to changes on how to get the database files.
## 1.21.0 - 2019-12-29
#### Added
* [#118](https://github.com/shlinkio/shlink/issues/118) API errors now implement the [problem details](https://tools.ietf.org/html/rfc7807) standard.
In order to make it backwards compatible, two things have been done:
* Both the old `error` and `message` properties have been kept on error response, containing the same values as the `type` and `detail` properties respectively.
* The API `v2` has been enabled. If an error occurs when calling the API with this version, the `error` and `message` properties will not be returned.
> After Shlink v2 is released, both API versions will behave like API v2.
* [#575](https://github.com/shlinkio/shlink/issues/575) Added support to filter short URL lists by date ranges.
* The `GET /short-urls` endpoint now accepts the `startDate` and `endDate` query params.
* The `short-urls:list` command now allows `--startDate` and `--endDate` flags to be optionally provided.
* [#338](https://github.com/shlinkio/shlink/issues/338) Added support to asynchronously notify external services via webhook, only when shlink is served with swoole.
Configured webhooks will receive a POST request every time a URL receives a visit, including information about the short URL and the visit.
The payload will look like this:
```json
{
"shortUrl": {},
"visit": {}
}
```
> The `shortUrl` and `visit` props have the same shape as it is defined in the [API spec](https://api-spec.shlink.io).
#### Changed
* [#492](https://github.com/shlinkio/shlink/issues/492) Updated to monolog 2, together with other dependencies, like Symfony 5 and infection-php.
* [#527](https://github.com/shlinkio/shlink/issues/527) Increased minimum required mutation score for unit tests to 80%.
* [#557](https://github.com/shlinkio/shlink/issues/557) Added a few php.ini configs for development and production docker images.
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#570](https://github.com/shlinkio/shlink/issues/570) Fixed shlink version generated for docker images when building from `develop` branch.
## 1.20.3 - 2019-12-23
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#585](https://github.com/shlinkio/shlink/issues/585) Fixed `PHP Fatal error: Uncaught Error: Class 'Shlinkio\Shlink\LocalLockFactory' not found` happening when running some CLI commands.
## 1.20.2 - 2019-12-06
#### Added
* *Nothing*
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#561](https://github.com/shlinkio/shlink/issues/561) Fixed `db:migrate` command failing because yaml extension is not installed, which makes config file not to be readable.
* [#562](https://github.com/shlinkio/shlink/issues/562) Fixed internal server error being returned when renaming a tag to another tag's name. Now a meaningful API error with status 409 is returned.
* [#555](https://github.com/shlinkio/shlink/issues/555) Fixed internal server error being returned when invalid dates are provided for new short URLs. Now a 400 is returned, as intended.
## 1.20.1 - 2019-11-17
#### Added
* [#519](https://github.com/shlinkio/shlink/issues/519) Documented how to customize web workers and task workers for the docker image.
#### Changed
* *Nothing*
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#512](https://github.com/shlinkio/shlink/issues/512) Fixed query params not being properly forwarded from short URL to long one.
* [#540](https://github.com/shlinkio/shlink/issues/540) Fixed errors thrown when creating short URLs if the original URL has an internationalized domain name and URL validation is enabled.
* [#528](https://github.com/shlinkio/shlink/issues/528) Ensured `db:create` and `db:migrate` commands do not silently fail when run as part of `install` or `update`.
* [#518](https://github.com/shlinkio/shlink/issues/518) Fixed service which updates Geolite db file to use a local lock instead of a shared one, since every shlink instance holds its own db instance.
## 1.20.0 - 2019-11-02
#### Added
* [#491](https://github.com/shlinkio/shlink/issues/491) Added improved short code generation logic.
Now, short codes are truly random, which removes the guessability factor existing in previous versions.
Generated short codes have 5 characters, and shlink makes sure they keep unique, while making it backwards-compatible.
* [#418](https://github.com/shlinkio/shlink/issues/418) and [#419](https://github.com/shlinkio/shlink/issues/419) Added support to redirect any 404 error to a custom URL.
It was already possible to configure this but only for invalid short URLs. Shlink now also support configuring redirects for the base URL and any other kind of "not found" error.
The three URLs can be different, and it is already possible to pass them to the docker image via configuration or env vars.
The installer also asks for these two new configuration options.
* [#497](https://github.com/shlinkio/shlink/issues/497) Officially added support for MariaDB.
#### Changed
* [#458](https://github.com/shlinkio/shlink/issues/458) Updated coding styles to use [shlinkio/php-coding-standard](https://github.com/shlinkio/php-coding-standard) v2.0.0.
#### Deprecated
* *Nothing*
#### Removed
* *Nothing*
#### Fixed
* [#507](https://github.com/shlinkio/shlink/issues/507) Fixed error with too long original URLs by increasing size to the maximum value (2048) based on [the standard](https://stackoverflow.com/a/417184).
* [#502](https://github.com/shlinkio/shlink/issues/502) Fixed error when providing the port as part of the domain on short URLs.
* [#509](https://github.com/shlinkio/shlink/issues/509) Fixed error when trying to generate a QR code for a short URL which uses a custom domain.
* [#522](https://github.com/shlinkio/shlink/issues/522) Highly mitigated errors thrown when lots of short URLs are created concurrently including new and existing tags.
## 1.19.0 - 2019-10-05
#### Added

View File

@@ -1,15 +1,14 @@
FROM php:7.3.8-cli-alpine3.10
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
FROM php:7.4.5-alpine3.11 as base
ARG SHLINK_VERSION=1.18.1
ARG SHLINK_VERSION=2.1.4
ENV SHLINK_VERSION ${SHLINK_VERSION}
ENV SWOOLE_VERSION 4.3.3
ENV COMPOSER_VERSION 1.9.0
ENV SWOOLE_VERSION 4.4.18
ENV LC_ALL "C"
WORKDIR /etc/shlink
RUN \
# Install mysl and calendar
# Install mysql and calendar
docker-php-ext-install -j"$(nproc)" pdo_mysql calendar && \
# Install sqlite
apk add --no-cache sqlite-libs sqlite-dev && \
@@ -17,31 +16,40 @@ RUN \
# Install postgres
apk add --no-cache postgresql-dev && \
docker-php-ext-install -j"$(nproc)" pdo_pgsql && \
# [Deprecated] Install intl
# Install intl
apk add --no-cache icu-dev && \
docker-php-ext-install -j"$(nproc)" intl && \
# Install zip and gd
apk add --no-cache libzip-dev zlib-dev libpng-dev && \
docker-php-ext-install -j"$(nproc)" zip gd
# Install swoole
# First line fixes an error when installing pecl extensions. Found in https://github.com/docker-library/php/issues/233
RUN apk add --no-cache --virtual .phpize-deps ${PHPIZE_DEPS} && \
pecl install swoole-${SWOOLE_VERSION} && \
docker-php-ext-enable swoole && \
apk del .phpize-deps
# Install swoole and sqlsrv driver
RUN wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.1.1-1_amd64.apk && \
apk add --allow-untrusted msodbcsql17_17.5.1.1-1_amd64.apk && \
apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS unixodbc-dev && \
pecl install swoole-${SWOOLE_VERSION} pdo_sqlsrv && \
docker-php-ext-enable swoole pdo_sqlsrv && \
apk del .phpize-deps && \
rm msodbcsql17_17.5.1.1-1_amd64.apk
# Install shlink
FROM base as builder
COPY . .
RUN rm -rf ./docker && \
wget https://getcomposer.org/download/${COMPOSER_VERSION}/composer.phar && \
COPY --from=composer:1.10.1 /usr/bin/composer ./composer.phar
RUN apk add --no-cache git && \
php composer.phar install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction && \
php composer.phar clear-cache && \
rm composer.*
rm -r docker composer.* && \
sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php
# Add shlink to the path to ease running it after container is created
# Prepare final image
FROM base
LABEL maintainer="Alejandro Celaya <alejandro@alejandrocelaya.com>"
COPY --from=builder /etc/shlink .
RUN ln -s /etc/shlink/bin/cli /usr/local/bin/shlink
RUN sed -i "s/%SHLINK_VERSION%/${SHLINK_VERSION}/g" config/autoload/app_options.global.php
# Expose swoole port
EXPOSE 8080
@@ -52,5 +60,6 @@ VOLUME /etc/shlink/config/params
# Copy config specific for the image
COPY docker/docker-entrypoint.sh docker-entrypoint.sh
COPY docker/config/shlink_in_docker.local.php config/autoload/shlink_in_docker.local.php
COPY docker/config/php.ini ${PHP_INI_DIR}/conf.d/
ENTRYPOINT ["/bin/sh", "./docker-entrypoint.sh"]

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016-2019 Alejandro Celaya
Copyright (c) 2016-2020 Alejandro Celaya
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

423
README.md
View File

@@ -1,37 +1,54 @@
# Shlink
![Shlink](https://raw.githubusercontent.com/shlinkio/shlink.io/master/public/images/shlink-hero.png)
[![Build Status](https://img.shields.io/travis/shlinkio/shlink.svg?style=flat-square)](https://travis-ci.org/shlinkio/shlink)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/shlinkio/shlink.svg?style=flat-square)](https://scrutinizer-ci.com/g/shlinkio/shlink/?branch=master)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/shlinkio/shlink.svg?style=flat-square)](https://scrutinizer-ci.com/g/shlinkio/shlink/?branch=master)
[![Latest Stable Version](https://img.shields.io/github/release/shlinkio/shlink.svg?style=flat-square)](https://packagist.org/packages/shlinkio/shlink)
[![Docker pulls](https://img.shields.io/docker/pulls/shlinkio/shlink.svg?style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/)
[![License](https://img.shields.io/github/license/shlinkio/shlink.svg?style=flat-square)](https://github.com/shlinkio/shlink/blob/master/LICENSE)
[![Paypal donate](https://img.shields.io/badge/Donate-paypal-blue.svg?style=flat-square&logo=paypal&colorA=aaaaaa)](https://acel.me/donate)
[![Paypal donate](https://img.shields.io/badge/Donate-paypal-blue.svg?style=flat-square&logo=paypal&colorA=aaaaaa)](https://slnk.to/donate)
A PHP-based self-hosted URL shortener that can be used to serve shortened URLs under your own custom domain.
> This document references Shlink 2.x. If you are using an older version and want to upgrade, follow the [UPGRADE](UPGRADE.md) doc.
## Table of Contents
- [Installation](#installation)
- [Download](#download)
- [Configure](#configure)
- [Serve](#serve)
- [Bonus](#bonus)
- [Update to new version](#update-to-new-version)
- [Using a docker image](#using-a-docker-image)
- [Using shlink](#using-shlink)
- [Shlink CLI Help](#shlink-cli-help)
- [Shlink CLI Help](#shlink-cli-help)
- [Multiple domains](#multiple-domains)
- [Management](#management)
- [Visits](#visits)
- [Special redirects](#special-redirects)
## Installation
First make sure the host where you are going to run shlink fulfills these requirements:
> These are the steps needed to install Shlink if you plan to manually host it.
>
> Alternatively, you can use the official docker image. If that's your intention, jump directly to [Using a docker image](#using-a-docker-image)
* PHP 7.2 or greater with JSON, APCu, intl, curl, PDO and gd extensions enabled.
* MySQL, PostgreSQL or SQLite.
First, make sure the host where you are going to run shlink fulfills these requirements:
* PHP 7.4 or greater with JSON, curl, PDO and gd extensions enabled.
* MySQL, MariaDB, PostgreSQL, Microsoft SQL Server or SQLite.
* The web server of your choice with PHP integration (Apache or Nginx recommended).
Then, you will need a built version of the project. There are a few ways to get it.
### Download
In order to run Shlink, you will need a built version of the project. There are two ways to get it.
* **Using a dist file**
The easiest way to install shlink is by using one of the pre-bundled distributable packages.
Just go to the [latest version](https://github.com/shlinkio/shlink/releases/latest) and download the `shlink_X.X.X_dist.zip` file you will find there.
Go to the [latest version](https://github.com/shlinkio/shlink/releases/latest) and download the `shlink_x.x.x_dist.zip` file you will find there.
Finally, decompress the file in the location of your choice.
@@ -43,185 +60,168 @@ Then, you will need a built version of the project. There are a few ways to get
* Download the [Composer](https://getcomposer.org/download/) PHP package manager inside the project folder.
* Run `./build.sh 1.0.0`, replacing the version with the version number you are going to build (the version number is only used for the generated dist file).
After that, you will have a `shlink_x.x.x_dist.zip` dist file inside the `build` directory.
After that, you will have a `shlink_x.x.x_dist.zip` dist file inside the `build` directory, that you need to decompress in the location fo your choice.
This is the process used when releasing new shlink versions. After tagging the new version with git, the Github release is automatically created by [travis](https://travis-ci.org/shlinkio/shlink), attaching generated dist file to it.
> This is the process used when releasing new shlink versions. After tagging the new version with git, the Github release is automatically created by [travis](https://travis-ci.org/shlinkio/shlink), attaching the generated dist file to it.
Despite how you built the project, you are going to need to install it now, by following these steps:
### Configure
* If you are going to use MySQL or PostgreSQL, create an empty database with the name of your choice.
Despite how you built the project, you now need to configure it, by following these steps:
* If you are going to use MySQL, MariaDB, PostgreSQL or Microsoft SQL Server, create an empty database with the name of your choice.
* Recursively grant write permissions to the `data` directory. Shlink uses it to cache some information.
* Setup the application by running the `bin/install` script. It is a command line tool that will guide you through the installation process. **Take into account that this tool has to be run directly on the server where you plan to host Shlink. Do not run it before uploading/moving it there.**
* Expose shlink to the web, either by using a traditional web server + fast CGI approach, or by using a [swoole](https://www.swoole.co.uk/) non-blocking server.
* **Using a web server:**
For example, assuming your domain is doma.in and shlink is in the `/path/to/shlink` folder, these would be the basic configurations for Nginx and Apache.
*Nginx:*
```nginx
server {
server_name doma.in;
listen 80;
root /path/to/shlink/public;
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}
```
*Apache:*
```apache
<VirtualHost *:80>
ServerName doma.in
DocumentRoot "/path/to/shlink/public"
<Directory "/path/to/shlink/public">
Options FollowSymLinks Includes ExecCGI
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```
* **Using swoole:**
**Important!** Swoole support is still experimental. Use it with care, and report any found issue.
First you need to install the swoole PHP extension with [pecl](https://pecl.php.net/package/swoole), `pecl install swoole`.
Once installed, it's actually pretty easy to get shlink up and running with swoole. Just run `./vendor/bin/zend-expressive-swoole start -d` and you will get shlink running on port 8080.
However, by doing it this way, you are loosing all the access logs, and the service won't be automatically run if the server has to be restarted.
For that reason, you should create a daemon script, in `/etc/init.d/shlink_swoole`, like this one, replacing `/path/to/shlink` by the path to your shlink installation:
```bash
#!/bin/bash
### BEGIN INIT INFO
# Provides: shlink_swoole
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Shlink non-blocking server with swoole
### END INIT INFO
SCRIPT=/path/to/shlink/vendor/bin/zend-expressive-swoole\ start
RUNAS=root
PIDFILE=/var/run/shlink_swoole.pid
LOGDIR=/var/log/shlink
LOGFILE=${LOGDIR}/shlink_swoole.log
start() {
if [[ -f "$PIDFILE" ]] && kill -0 $(cat "$PIDFILE"); then
echo 'Shlink with swoole already running' >&2
return 1
fi
echo 'Starting shlink with swoole' >&2
mkdir -p "$LOGDIR"
touch "$LOGFILE"
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Shlink started' >&2
}
stop() {
if [[ ! -f "$PIDFILE" ]] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Shlink with swoole not running' >&2
return 1
fi
echo 'Stopping shlink with swoole' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Shlink stopped' >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
```
Then run these commands to enable the service and start it:
* `sudo chmod +x /etc/init.d/shlink_swoole`
* `sudo update-rc.d shlink_swoole defaults`
* `sudo update-rc.d shlink_swoole enable`
* `/etc/init.d/shlink_swoole start`
Now again, you can access shlink on port 8080, but this time the service will be automatically run at system start-up, and all access logs will be written in `/var/log/shlink/shlink_swoole.log` (you will probably want to [rotate those logs](https://www.digitalocean.com/community/tutorials/how-to-manage-logfiles-with-logrotate-on-ubuntu-16-04). You can find an example logrotate config file [here](data/infra/examples/shlink-daemon-logrotate.conf)).
* Generate your first API key by running `bin/cli api-key:generate`. You will need the key in order to interact with shlink's API.
* Finally access to [https://app.shlink.io](https://app.shlink.io) and configure your server to start creating short URLs.
**Bonus**
### Serve
There are a couple of time-consuming tasks that shlink expects you to do manually, or at least it is recommended, since it will improve runtime performance.
Once Shlink is configured, you need to expose it to the web, either by using a traditional web server + fast CGI approach, or by using a [swoole](https://www.swoole.co.uk/) non-blocking server.
Those tasks can be performed using shlink's CLI, so it should be easy to schedule them to be run in the background (for example, using cron jobs):
* **Using a web server:**
* **For shlink older than 1.18.0 or not using swoole as the web server**: Resolve IP address locations: `/path/to/shlink/bin/cli visit:locate`
For example, assuming your domain is doma.in and shlink is in the `/path/to/shlink` folder, these would be the basic configurations for Nginx and Apache.
If you don't run this command regularly, the stats will say all visits come from *unknown* locations.
*Nginx:*
* Generate website previews: `/path/to/shlink/bin/cli short-url:process-previews`
```nginx
server {
server_name doma.in;
listen 80;
root /path/to/shlink/public;
index index.php;
charset utf-8;
Running this will improve the performance of the `doma.in/abc123/preview` URLs, which return a preview of the site.
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
> **Important!** Generating previews is considered deprecated and the feature will be removed in Shlink v2.
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
* **For shlink older than v1.17.0**: Update IP geolocation database: `/path/to/shlink/bin/cli visit:update-db`
location ~ /\.ht {
deny all;
}
}
```
When shlink is installed it downloads a fresh [GeoLite2](https://dev.maxmind.com/geoip/geoip2/geolite2/) db file. Running this command will update this file.
*Apache:*
The file is updated the first Tuesday of every month, so it should be enough running this command the first Wednesday.
```apache
<VirtualHost *:80>
ServerName doma.in
DocumentRoot "/path/to/shlink/public"
*Any of these commands accept the `-q` flag, which makes it not display any output. This is recommended when configuring the commands as cron jobs.*
<Directory "/path/to/shlink/public">
Options FollowSymLinks Includes ExecCGI
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```
> In future versions, it is planed that, when using **swoole** to serve shlink, some of these tasks are automatically run without blocking the request and also, without having to configure cron jobs. Probably resolving IP locations and generating previews.
* **Using swoole:**
First you need to install the swoole PHP extension with [pecl](https://pecl.php.net/package/swoole), `pecl install swoole`.
Once installed, it's actually pretty easy to get shlink up and running with swoole. Run `./vendor/bin/mezzio-swoole start -d` and you will get shlink running on port 8080.
However, by doing it this way, you are loosing all the access logs, and the service won't be automatically run if the server has to be restarted.
For that reason, you should create a daemon script, in `/etc/init.d/shlink_swoole`, like this one, replacing `/path/to/shlink` by the path to your shlink installation:
```bash
#!/bin/bash
### BEGIN INIT INFO
# Provides: shlink_swoole
# Required-Start: $local_fs $network $named $time $syslog
# Required-Stop: $local_fs $network $named $time $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Shlink non-blocking server with swoole
### END INIT INFO
SCRIPT=/path/to/shlink/vendor/bin/mezzio-swoole\ start
RUNAS=root
PIDFILE=/var/run/shlink_swoole.pid
LOGDIR=/var/log/shlink
LOGFILE=${LOGDIR}/shlink_swoole.log
start() {
if [[ -f "$PIDFILE" ]] && kill -0 $(cat "$PIDFILE"); then
echo 'Shlink with swoole already running' >&2
return 1
fi
echo 'Starting shlink with swoole' >&2
mkdir -p "$LOGDIR"
touch "$LOGFILE"
local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
su -c "$CMD" $RUNAS > "$PIDFILE"
echo 'Shlink started' >&2
}
stop() {
if [[ ! -f "$PIDFILE" ]] || ! kill -0 $(cat "$PIDFILE"); then
echo 'Shlink with swoole not running' >&2
return 1
fi
echo 'Stopping shlink with swoole' >&2
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
echo 'Shlink stopped' >&2
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
```
Then run these commands to enable the service and start it:
* `sudo chmod +x /etc/init.d/shlink_swoole`
* `sudo update-rc.d shlink_swoole defaults`
* `sudo update-rc.d shlink_swoole enable`
* `/etc/init.d/shlink_swoole start`
Now again, you can access shlink on port 8080, but this time the service will be automatically run at system start-up, and all access logs will be written in `/var/log/shlink/shlink_swoole.log` (you will probably want to [rotate those logs](https://www.digitalocean.com/community/tutorials/how-to-manage-logfiles-with-logrotate-on-ubuntu-16-04). You can find an example logrotate config file [here](data/infra/examples/shlink-daemon-logrotate.conf)).
Finally access to [https://app.shlink.io](https://app.shlink.io) and configure your server to start creating short URLs.
### Bonus
Geo-locating visits to your short links is a time-consuming task. When serving Shlink with swoole, the geo-location task is automatically run asynchronously just after a visit to a short URL happens.
However, if you are not serving Shlink with swoole, you will have to schedule the geo-location task to be run regularly in the background (for example, using cron jobs):
The command you need to run is `/path/to/shlink/bin/cli visit:locate`, and you can optionally provide the `-q` flag to remove any output and avoid your cron logs to be polluted.
## Update to new version
When a new Shlink version is available, you don't need to repeat the entire process yourself. Instead, follow these steps:
When a new Shlink version is available, you don't need to repeat the entire process. Instead, follow these steps:
1. Rename your existing Shlink directory to something else (ie. `shlink` ---> `shlink-old`).
2. Download and extract the new version of Shlink, and set the directories name to that of the old version. (ie. `shlink`).
3. Run the `bin/update` script in the new version's directory to migrate your configuration over.
2. Download and extract the new version of Shlink, and set the directory name to that of the old version (ie. `shlink`).
3. Run the `bin/update` script in the new version's directory to migrate your configuration over. You will be asked to provide the path to the old instance (ie. `shlink-old`).
4. If you are using shlink with swoole, restart the service by running `/etc/init.d/shlink_swoole restart`.
The `bin/update` script will ask you for the location from previous shlink version, and use it in order to import the configuration. It will then update the database and generate some assets shlink needs to work.
The `bin/update` will use the location from previous shlink version to import the configuration. It will then update the database and generate some assets shlink needs to work.
Right now, it does not import cached info (like website previews), but it will. For now you will need to regenerate them again.
**Important!** It is recommended that you don't skip any version when using this process. The update gets better on every version, but older versions might make assumptions.
**Important!** It is recommended that you don't skip any version when using this process. The update tool gets better on every version, but older versions might make assumptions.
## Using a docker image
@@ -239,7 +239,7 @@ Once shlink is installed, there are two main ways to interact with it:
It is probably a good idea to symlink the CLI entry point (`bin/cli`) to somewhere in your path, so that you can run shlink from any directory.
* **The REST API**. The complete docs on how to use the API can be found [here](https://shlink.io/api-docs), and a sandbox which also documents every endpoint can be found [here](https://shlink.io/swagger-ui/index.html).
* **The REST API**. The complete docs on how to use the API can be found [here](https://shlink.io/documentation/api-docs), and a sandbox which also documents every endpoint can be found in the [API Spec](https://api-spec.shlink.io/) portal.
However, you probably don't want to consume the raw API yourself. That's why a nice [web client](https://github.com/shlinkio/shlink-web-client) is provided that can be directly used from [https://app.shlink.io](https://app.shlink.io), or you can host it yourself too.
@@ -261,33 +261,90 @@ Options:
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
help Displays help for a command
list Lists commands
api-key
api-key:disable Disables an API key.
api-key:generate Generates a new valid API key.
api-key:list Lists all the available API keys.
config
config:generate-charset [DEPRECATED] Generates a character set sample just by shuffling the default one, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ". Then it can be set in the SHORTCODE_CHARS environment variable
config:generate-secret [DEPRECATED] Generates a random secret string that can be used for JWT token encryption
api-key:disable Disables an API key.
api-key:generate Generates a new valid API key.
api-key:list Lists all the available API keys.
db
db:create Creates the database needed for shlink to work. It will do nothing if the database already exists
db:migrate Runs database migrations, which will ensure the shlink database is up to date.
db:create Creates the database needed for shlink to work. It will do nothing if the database already exists
db:migrate Runs database migrations, which will ensure the shlink database is up to date.
short-url
short-url:delete [short-code:delete] Deletes a short URL
short-url:generate [shortcode:generate|short-code:generate] Generates a short URL for provided long URL and returns it
short-url:list [shortcode:list|short-code:list] List all short URLs
short-url:parse [shortcode:parse|short-code:parse] Returns the long URL behind a short code
short-url:process-previews [shortcode:process-previews|short-code:process-previews] [DEPRECATED] Processes and generates the previews for every URL, improving performance for later web requests.
short-url:visits [shortcode:visits|short-code:visits] Returns the detailed visits information for provided short code
short-url:delete Deletes a short URL
short-url:generate Generates a short URL for provided long URL and returns it
short-url:list List all short URLs
short-url:parse Returns the long URL behind a short code
short-url:visits Returns the detailed visits information for provided short code
tag
tag:create Creates one or more tags.
tag:delete Deletes one or more tags.
tag:list Lists existing tags.
tag:rename Renames one existing tag.
tag:create Creates one or more tags.
tag:delete Deletes one or more tags.
tag:list Lists existing tags.
tag:rename Renames one existing tag.
visit
visit:locate [visit:process] Resolves visits origin locations.
visit:update-db [DEPRECATED] Updates the GeoLite2 database file used to geolocate IP addresses
visit:locate Resolves visits origin locations.
```
## Multiple domains
While in many cases you will just have one short domain and you'll want all your short URLs to be served from it, there are some cases in which you might want to have multiple short domains served from the same Shlink instance.
If that's the case, you need to understand how Shlink will behave when managing your short URLs or any of them is visited.
### Management
When you create a short URL it is possible to optionally pass a `domain` param. If you don't pass it, the short URL will be created for the default domain (the one provided during Shlink's installation or in the `SHORT_DOMAIN_HOST` env var when using the docker image).
However, if you pass it, the short URL will be "linked" to that domain.
> Note that, if the default domain is passed, Shlink will ignore it and will behave as if no `domain` param was provided.
The main benefit of being able to pass the domain is that Shlink will allow the same custom slug to be used in multiple short URLs, as long as the domain is different (like `example.com/my-compaign`, `another.com/my-compaign` and `foo.com/my-compaign`).
Then, each short URL will be tracked separately and you will be able to define specific tags and metadata for each one of them.
However, this has a side effect. When you try to interact with an existing short URL (editing tags, editing meta, resolving it or deleting it), either from the REST API or the CLI tool, you will have to provide the domain appropriately.
Let's imagine this situation. Shlink's default domain is `example.com`, and you have the next short URLs:
* `https://example.com/abc123` -> a regular short URL where no domain was provided.
* `https://example.com/my-campaign` -> a regular short URL where no domain was provided, but it has a custom slug.
* `https://another.com/my-campaign` -> a short URL where the `another.com` domain was provided, and it has a custom slug.
* `https://another.com/def456` -> a short URL where the `another.com` domain was provided.
These are some of the results you will get when trying to interact with them, depending on the params you provide:
* Providing just the `abc123` short code -> the first URL will be matched.
* Providing just the `my-campaign` short code -> the second URL will be matched, since you did not specify a domain, therefor, Shlink looks for the one with the short code/slug `my-campaign` which is also linked to default domain (or not linked to any domain, to be more accurate).
* Providing the `my-campaign` short code and the `another.com` domain -> The third one will be matched.
* Providing just the `def456` short code -> Shlink will fail/not find any short URL, since there's none with the short code `def456` linked to default domain.
* Providing the `def456` short code and the `another.com` domain -> The fourth short URL will be matched.
* Providing any short code and the `foo.com` domain -> Again, no short URL will be found, as there's none linked to `foo.com` domain.
### Visits
Before adding support for multiple domains, you could point as many domains as you wanted to Shlink, and they would have always worked for existing short codes/slugs.
In order to keep backwards compatibility, Shlink's behavior when a short URL is visited is slightly different, getting to fallback in some cases.
Let's continue with previous example, and also consider we have three domains that will resolve to our Shlink instance, which are `example.com`, `another.com` and `foo.com`.
With that in mind, this is how Shlink will behave when the next short URLs are visited:
* `https://another.com/abc123` -> There was no short URL specifically defined for domain `another.com` and short code `abc123`, but it exists for default domain (`example.com`), so it will fall back to it and redirect to where `example.com/abc123` is configured to redirect.
* `https://example.com/def456` -> The fall-back does not happen from default domain to specific ones, only the other way around (like in previous case). Because of that, this one will result in a not-found URL, even though the `def456` short code exists for `another.com` domain.
* `https://foo.com/abc123` -> This will also fall-back to `example.com/abc123`, like in the first case.
* `https://another.com/non-existing` -> The combination of `another.com` domain with the `non-existing` slug does not exist, so Shlink will try to fall-back to the same but for default domain (`example.com`). However, since that combination does not exist either, it will result in a not-found URL.
* Any other short URL visited exactly as it was configured will, of course, resolve as expected.
### Special redirects
It is currently possible to configure some special redirects when the base domain is visited, a URL does not match, or an invalid/disabled short URL is visited.
Those are configured during Shlink's installation or via env vars when using the docker image.
Currently those are all shared for all domains serving the same Shlink instance, but the plan is to update that and allow specific ones for every existing domain.
---
> This product includes GeoLite2 data created by MaxMind, available from [https://www.maxmind.com](https://www.maxmind.com)

88
UPGRADE.md Normal file
View File

@@ -0,0 +1,88 @@
# Upgrading
## From v1.x to v2.x
### PHP 7.4 required
This new version takes advantage of several new features introduced in PHP 7.4.
Thanks to that, the code is more reliable and robust, and easier to maintain and improve.
However, that means that any previous PHP version is no longer supported.
### Preview generation
The ability to generate website previews has been completely removed and has no replacement.
The feature never properly worked, and it wasn't really useful. Because of that, the feature is no longer available on Shlink 2.x
Removing this feature has these implications:
* The `short-url:process-previews` CLI command no longer exists, and an error will be thrown if executed.
* The `/{shortCode}/preview` path is no longer valid, and will return a 404 status.
### Removed paths
These routes have been removed, but have a direct replacement:
* `/qr/{shortCode}[/{size}]` -> `/{shortCode}/qr-code[/{size}]`
* `PUT /rest/v{version}/short-urls/{shortCode}` -> `PATCH /rest/v{version}/short-urls/{shortCode}`
When using the old ones, a 404 status will me returned now.
### Removed command and route aliases
All the aliases for the CLI commands in the `short-urls` namespace have been removed. If you were using any of those commands with the `shortcode` or `short-code` prefixes, make sure to update them to use the `short-urls` prefix instead.
The same happens for all REST endpoints starting with `/short-code`. They were previously aliased to `/short-urls` ones, but they will return a 404 now. Make sure to update them accordingly.
### JWT authentication removed
Shlink's REST API no longer accepts authentication using a JWT token. The API key has to be passed now in the `x-api-key` header.
Removing this feature has these implications:
* Shlink will no longer introspect the `Authorization` header for Bearer tokens.
* The `POST /rest/v{version}/authenticate` endpoint no longer exists and will return a 404.
### API version is now required
Endpoints need to provide a version in the path now. Previously, not providing a version used to fall back to v1. Now, it will return a 404 status, as no route will match.
The only exception is the `/rest/health` endpoint, which will continue working without the version.
### API errors
Shlink v1.21.0 introduced support for API errors using the Problem Details format, as well as the v2 of the API.
For backwards compatibility reasons, requests performed to v1 continued to return the old `error` and `message` properties.
Starting with Shlink v2.0.0, both versions of the API will no longer return those two properties.
As a replacement, use `type` instead of `error`, and `detail` instead of `message`.
### Changes in models
The next REST API models have changed:
* **ShortUrl**: The `originalUrl` property was deprecated and has been removed. Use `longUrl` instead.
* **Visit**: The `remoteAddr` property was deprecated and has been removed. It has no replacement.
* **VisitLocation**: The `latitude` and `longitude` properties are no longer strings, but float.
### URL validation
Shlink can verify provided long URLs are valid before trying to shorten them. Starting with v2, it no longer does it by default and needs to be explicitly enabled instead of explicitly disabled.
### Removed config options
The `not_found_redirect_to` config option and the `NOT_FOUND_REDIRECT_TO` env var are no longer taken into consideration for the docker image.
Instead, use `invalid_short_url_redirect_to` and `INVALID_SHORT_URL_REDIRECT_TO` respectively.
### Migrated to Laminas
The project has been using Zend Framework components since the beginning. Since it has been re-branded as [Laminas](https://getlaminas.org/), this version updates to the new set of components.
Updating to Laminas components has these implications:
* If you were manually serving Shlink with swoole, the entry script has to be changed from `/path/to/shlink/vendor/bin/zend-expressive-swoole` to `/path/to/shlink/vendor/bin/mezzio-swoole`

View File

@@ -1,10 +1,7 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Application as CliApp;
/** @var ContainerInterface $container */
$container = include __DIR__ . '/../config/container.php';
$container->get(CliApp::class)->run();
$run = require __DIR__ . '/../config/run.php';
$run(true);

View File

@@ -8,5 +8,5 @@ use function chdir;
use function dirname;
chdir(dirname(__DIR__));
$run = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php';
$run(false);
[$install] = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php';
$install();

View File

@@ -1,14 +1,18 @@
#!/usr/bin/env sh
set -e
export APP_ENV=test
export DB_DRIVER=mysql
# Try to stop server just in case it hanged in last execution
vendor/bin/zend-expressive-swoole stop
vendor/bin/mezzio-swoole stop
echo 'Starting server...'
vendor/bin/zend-expressive-swoole start -d
vendor/bin/mezzio-swoole start -d
sleep 2
vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always
vendor/bin/zend-expressive-swoole stop
phpdbg -qrr vendor/bin/phpunit --order-by=random -c phpunit-api.xml --testdox --colors=always $*
testsExitCode=$?
vendor/bin/mezzio-swoole stop
# Exit this script with the same code as the tests. If tests failed, this script has to fail
exit $testsExitCode

View File

@@ -8,5 +8,5 @@ use function chdir;
use function dirname;
chdir(dirname(__DIR__));
$run = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php';
$run(true);
[, $update] = require __DIR__ . '/../vendor/shlinkio/shlink-installer/bin/run.php';
$update();

Binary file not shown.

View File

@@ -19,13 +19,14 @@ mkdir -p "${builtcontent}"
rsync -av * "${builtcontent}" \
--exclude=*docker* \
--exclude=Dockerfile \
--include=.htaccess \
--exclude-from=./.dockerignore
cd "${builtcontent}"
# Install dependencies
echo "Installing dependencies with $composerBin..."
${composerBin} self-update
${composerBin} install --no-dev --optimize-autoloader --no-progress --no-interaction
${composerBin} install --no-dev --optimize-autoloader --prefer-dist --no-progress --no-interaction
# Delete development files
echo 'Deleting dev files...'

View File

@@ -12,72 +12,74 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.4",
"ext-json": "*",
"ext-pdo": "*",
"acelaya/ze-content-based-error-handler": "^3.0",
"akrabat/ip-address-middleware": "^1.0",
"cakephp/chronos": "^1.2",
"cocur/slugify": "^3.0",
"doctrine/cache": "^1.6",
"doctrine/dbal": "^2.9",
"doctrine/migrations": "^2.0",
"doctrine/orm": "^2.5",
"endroid/qr-code": "^1.7",
"firebase/php-jwt": "^4.0",
"doctrine/cache": "^1.9",
"doctrine/dbal": "^2.10",
"doctrine/migrations": "^2.2",
"doctrine/orm": "^2.7",
"endroid/qr-code": "^3.6",
"geoip2/geoip2": "^2.9",
"guzzlehttp/guzzle": "^6.3",
"guzzlehttp/guzzle": "^6.5.1",
"laminas/laminas-config": "^3.3",
"laminas/laminas-config-aggregator": "^1.1",
"laminas/laminas-dependency-plugin": "^1.0",
"laminas/laminas-diactoros": "^2.1.3",
"laminas/laminas-inputfilter": "^2.10",
"laminas/laminas-paginator": "^2.8",
"laminas/laminas-servicemanager": "^3.4",
"laminas/laminas-stdlib": "^3.2",
"lcobucci/jwt": "^4.0@alpha",
"lstrojny/functional-php": "^1.9",
"mikehaertl/phpwkhtmltopdf": "^2.2",
"monolog/monolog": "^1.24",
"ocramius/proxy-manager": "~2.2.2",
"mezzio/mezzio": "^3.2",
"mezzio/mezzio-fastroute": "^3.0",
"mezzio/mezzio-helpers": "^5.3",
"mezzio/mezzio-platesrenderer": "^2.1",
"mezzio/mezzio-problem-details": "^1.1",
"mezzio/mezzio-swoole": "^2.6.4",
"monolog/monolog": "^2.0",
"nikolaposa/monolog-factory": "^3.0",
"ocramius/proxy-manager": "^2.7.0",
"phly/phly-event-dispatcher": "^1.0",
"php-middleware/request-id": "^4.0",
"predis/predis": "^1.1",
"shlinkio/shlink-common": "^2.0",
"shlinkio/shlink-event-dispatcher": "^1.0",
"shlinkio/shlink-installer": "^2.0",
"shlinkio/shlink-ip-geolocation": "^1.0",
"symfony/console": "^4.3",
"symfony/filesystem": "^4.3",
"symfony/lock": "^4.3",
"symfony/process": "^4.3",
"theorchard/monolog-cascade": "^0.5",
"zendframework/zend-config": "^3.3",
"zendframework/zend-config-aggregator": "^1.1",
"zendframework/zend-diactoros": "^2.1.3",
"zendframework/zend-expressive": "^3.2",
"zendframework/zend-expressive-fastroute": "^3.0",
"zendframework/zend-expressive-helpers": "^5.3",
"zendframework/zend-expressive-platesrenderer": "^2.1",
"zendframework/zend-expressive-swoole": "^2.4",
"zendframework/zend-inputfilter": "^2.10",
"zendframework/zend-paginator": "^2.8",
"zendframework/zend-servicemanager": "^3.4",
"zendframework/zend-stdlib": "^3.2"
"pugx/shortid-php": "^0.5",
"ramsey/uuid": "^3.9",
"shlinkio/shlink-common": "^3.1.0",
"shlinkio/shlink-config": "^1.0",
"shlinkio/shlink-event-dispatcher": "^1.4",
"shlinkio/shlink-installer": "^5.0.0",
"shlinkio/shlink-ip-geolocation": "^1.4",
"symfony/console": "^5.0",
"symfony/filesystem": "^5.0",
"symfony/lock": "^5.0",
"symfony/mercure": "^0.3.0",
"symfony/process": "^5.0"
},
"require-dev": {
"devster/ubench": "^2.0",
"dms/phpunit-arraysubset-asserts": "^0.2.0",
"eaglewu/swoole-ide-helper": "dev-master",
"filp/whoops": "^2.4",
"infection/infection": "^0.13.4",
"phpstan/phpstan": "^0.11.2",
"phpunit/phpcov": "^6.0",
"phpunit/phpunit": "^8.3",
"infection/infection": "^0.16.1",
"phpstan/phpstan": "^0.12.18",
"phpunit/phpunit": "~9.0.1",
"roave/security-advisories": "dev-master",
"shlinkio/php-coding-standard": "~1.2.2",
"shlinkio/shlink-test-utils": "^1.0",
"symfony/dotenv": "^4.3",
"symfony/var-dumper": "^4.3",
"zendframework/zend-component-installer": "^2.1",
"zendframework/zend-expressive-tooling": "^1.2"
"shlinkio/php-coding-standard": "~2.1.0",
"shlinkio/shlink-test-utils": "^1.4",
"symfony/var-dumper": "^5.0"
},
"autoload": {
"psr-4": {
"Shlinkio\\Shlink\\CLI\\": "module/CLI/src",
"Shlinkio\\Shlink\\Rest\\": "module/Rest/src",
"Shlinkio\\Shlink\\Core\\": "module/Core/src",
"Shlinkio\\Shlink\\PreviewGenerator\\": "module/PreviewGenerator/src/"
}
"Shlinkio\\Shlink\\Core\\": "module/Core/src"
},
"files": [
"module/Core/functions/functions.php"
]
},
"autoload-dev": {
"psr-4": {
@@ -87,8 +89,7 @@
"ShlinkioTest\\Shlink\\Core\\": [
"module/Core/test",
"module/Core/test-db"
],
"ShlinkioTest\\Shlink\\PreviewGenerator\\": "module/PreviewGenerator/test"
]
}
},
"scripts": {
@@ -98,11 +99,9 @@
"@test:ci",
"@infect:ci"
],
"cs": "phpcs",
"cs:fix": "phpcbf",
"stan": "phpstan analyse module/*/src/ module/*/config config docker/config --level=5 -c phpstan.neon",
"stan": "phpstan analyse module/*/src/ module/*/config config docker/config --level=6",
"test": [
"@test:unit",
"@test:db",
@@ -111,36 +110,35 @@
"test:ci": [
"@test:unit:ci",
"@test:db",
"@test:api"
"@test:api:ci"
],
"test:unit": "phpdbg -qrr vendor/bin/phpunit --order-by=random --colors=always --coverage-php build/coverage-unit.cov --testdox",
"test:unit:ci": "phpdbg -qrr vendor/bin/phpunit --order-by=random --colors=always --coverage-php build/coverage-unit.cov --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/phpunit.junit.xml --testdox",
"test:unit:ci": "@test:unit --coverage-clover=build/clover.xml --coverage-xml=build/coverage-xml --log-junit=build/junit.xml",
"test:db": [
"@test:db:sqlite",
"@test:db:mysql",
"@test:db:postgres"
"@test:db:maria",
"@test:db:postgres",
"@test:db:ms"
],
"test:db:sqlite": "APP_ENV=test phpdbg -qrr vendor/bin/phpunit --order-by=random --colors=always -c phpunit-db.xml --coverage-php build/coverage-db.cov --testdox",
"test:db:sqlite": "APP_ENV=test phpdbg -qrr vendor/bin/phpunit --order-by=random --colors=always --coverage-php build/coverage-db.cov --testdox -c phpunit-db.xml",
"test:db:mysql": "DB_DRIVER=mysql composer test:db:sqlite",
"test:db:maria": "DB_DRIVER=maria composer test:db:sqlite",
"test:db:postgres": "DB_DRIVER=postgres composer test:db:sqlite",
"test:db:ms": "DB_DRIVER=mssql composer test:db:sqlite",
"test:api": "bin/test/run-api-tests.sh",
"test:pretty": [
"@test",
"phpdbg -qrr vendor/bin/phpcov merge build --html build/html"
],
"test:api:ci": "@test:api --coverage-php build/coverage-api.cov",
"test:unit:pretty": "phpdbg -qrr vendor/bin/phpunit --order-by=random --colors=always --coverage-html build/coverage",
"infect": "infection --threads=4 --min-msi=75 --log-verbosity=default --only-covered",
"infect:ci": "infection --threads=4 --min-msi=75 --log-verbosity=default --only-covered --coverage=build",
"infect:show": "infection --threads=4 --min-msi=75 --log-verbosity=default --only-covered --show-mutations",
"infect": "infection --threads=4 --min-msi=80 --log-verbosity=default --only-covered",
"infect:ci": "@infect --coverage=build --skip-initial-tests",
"infect:show": "@infect --show-mutations",
"infect:test": [
"@test:unit:ci",
"@infect:ci"
]
],
"clean:dev": "rm -f data/database.sqlite && rm -f config/params/generated_config.php"
},
"scripts-descriptions": {
"check": "<fg=blue;options=bold>Alias for \"cs\", \"stan\", \"test\" and \"infect\"</>",
"ci": "<fg=blue;options=bold>Alias for \"cs\", \"stan\", \"test:ci\" and \"infect:ci\"</>",
"cs": "<fg=blue;options=bold>Checks coding styles</>",
"cs:fix": "<fg=blue;options=bold>Fixes coding styles, when possible</>",
@@ -149,17 +147,18 @@
"test:ci": "<fg=blue;options=bold>Runs all test suites, generating all needed reports and logs for CI envs</>",
"test:unit": "<fg=blue;options=bold>Runs unit test suites</>",
"test:unit:ci": "<fg=blue;options=bold>Runs unit test suites, generating all needed reports and logs for CI envs</>",
"test:db": "<fg=blue;options=bold>Runs database test suites on a SQLite, MySQL and PostgreSQL</>",
"test:db": "<fg=blue;options=bold>Runs database test suites on a SQLite, MySQL, MariaDB, PostgreSQL and MsSQL</>",
"test:db:sqlite": "<fg=blue;options=bold>Runs database test suites on a SQLite database</>",
"test:db:mysql": "<fg=blue;options=bold>Runs database test suites on a MySQL database</>",
"test:db:maria": "<fg=blue;options=bold>Runs database test suites on a MariaDB database</>",
"test:db:postgres": "<fg=blue;options=bold>Runs database test suites on a PostgreSQL database</>",
"test:api": "<fg=blue;options=bold>Runs API test suites</>",
"test:pretty": "<fg=blue;options=bold>Runs all test suites and generates an HTML code coverage report</>",
"test:unit:pretty": "<fg=blue;options=bold>Runs unit test suites and generates an HTML code coverage report</>",
"infect": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing</>",
"infect:ci": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing with existing reports and logs</>",
"infect:show": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing and shows applied mutators</>",
"infect:test": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing</>"
"infect:test": "<fg=blue;options=bold>Checks unit tests quality applying mutation testing</>",
"clean:dev": "<fg=blue;options=bold>Deletes artifacts which are gitignored and could affect dev env</>"
},
"config": {
"sort-packages": true

View File

@@ -1,14 +1,12 @@
<?php
declare(strict_types=1);
use function Shlinkio\Shlink\Common\env;
declare(strict_types=1);
return [
'app_options' => [
'name' => 'Shlink',
'version' => '%SHLINK_VERSION%',
'secret_key' => env('SECRET_KEY', ''),
'disable_track_param' => null,
],

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
return [
@@ -6,11 +7,11 @@ return [
'ip_address_resolution' => [
'headers_to_inspect' => [
'CF-Connecting-IP',
'True-Client-IP',
'X-Real-IP',
'Forwarded',
'X-Forwarded-For',
'X-Forwarded',
'Forwarded',
'True-Client-IP',
'X-Real-IP',
'X-Cluster-Client-Ip',
'Client-Ip',
],

View File

@@ -1,7 +1,8 @@
<?php
declare(strict_types=1);
use Zend\ConfigAggregator\ConfigAggregator;
use Laminas\ConfigAggregator\ConfigAggregator;
return [

View File

@@ -1,7 +1,8 @@
<?php
declare(strict_types=1);
use Zend\ConfigAggregator\ConfigAggregator;
use Laminas\ConfigAggregator\ConfigAggregator;
return [

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink;

View File

@@ -1,14 +1,14 @@
<?php
declare(strict_types=1);
use Zend\Expressive;
use Zend\Expressive\Container;
use Mezzio\Container;
return [
'dependencies' => [
'delegators' => [
Expressive\Application::class => [
Mezzio\Application::class => [
Container\ApplicationConfigInjectionDelegator::class,
],
],

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Psr\Container\ContainerInterface;
@@ -12,7 +13,7 @@ return [
],
'initializers' => [
function (ContainerInterface $container, $instance) {
function (ContainerInterface $container, $instance): void {
if ($instance instanceof Log\LoggerAwareInterface) {
$instance->setLogger($container->get(Log\LoggerInterface::class));
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\Common;
@@ -8,11 +9,12 @@ return [
'entity_manager' => [
'orm' => [
'proxies_dir' => 'data/proxies',
'load_mappings_using_functional_style' => true,
],
'connection' => [
'user' => env('DB_USER'),
'password' => env('DB_PASSWORD'),
'dbname' => env('DB_NAME', 'shlink'),
'user' => '',
'password' => '',
'dbname' => 'shlink',
'charset' => 'utf8',
],
],

View File

@@ -1,13 +1,24 @@
<?php
declare(strict_types=1);
use function Shlinkio\Shlink\Common\env;
// When running tests, any mysql-specific option can interfere with other drivers
$driverOptions = env('APP_ENV') === 'test' ? [] : [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
];
return [
'entity_manager' => [
'connection' => [
'user' => 'root',
'password' => 'root',
'driver' => 'pdo_mysql',
'host' => 'shlink_db',
'driverOptions' => [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
],
'driverOptions' => $driverOptions,
],
],

View File

@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
use Laminas\Stratigility\Middleware\ErrorHandler;
use Mezzio\ProblemDetails\ProblemDetailsMiddleware;
use Shlinkio\Shlink\Common\Logger;
return [
'problem-details' => [
'default_types_map' => [
404 => 'NOT_FOUND',
500 => 'INTERNAL_SERVER_ERROR',
],
],
'error_handler' => [
'listeners' => [Logger\ErrorLogger::class],
],
'dependencies' => [
'delegators' => [
ErrorHandler::class => [
Logger\ErrorHandlerListenerAttachingDelegator::class,
],
ProblemDetailsMiddleware::class => [
Logger\ErrorHandlerListenerAttachingDelegator::class,
],
],
],
];

View File

@@ -1,29 +0,0 @@
<?php
declare(strict_types=1);
use Zend\Expressive\Container\WhoopsErrorResponseGeneratorFactory;
return [
'dependencies' => [
'invokables' => [
'Zend\Expressive\Whoops' => Whoops\Run::class,
'Zend\Expressive\WhoopsPageHandler' => Whoops\Handler\PrettyPageHandler::class,
],
],
'whoops' => [
'json_exceptions' => [
'display' => true,
'show_trace' => true,
'ajax_only' => true,
],
],
'error_handler' => [
'plugins' => [
'factories' => [
'text/html' => WhoopsErrorResponseGeneratorFactory::class,
],
],
],
];

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
return [
@@ -6,7 +7,7 @@ return [
'geolite2' => [
'db_location' => __DIR__ . '/../../data/GeoLite2-City.mmdb',
'temp_dir' => sys_get_temp_dir(),
'download_from' => 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz',
'license_key' => 'G4Lm0C60yJsnkdPi',
],
];

View File

@@ -1,44 +1,51 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Installer\Config\Plugin;
use Shlinkio\Shlink\Installer\Config\Option;
return [
'installer_plugins_expected_config' => [
Plugin\UrlShortenerConfigCustomizer::class => [
Plugin\UrlShortenerConfigCustomizer::SCHEMA,
Plugin\UrlShortenerConfigCustomizer::HOSTNAME,
Plugin\UrlShortenerConfigCustomizer::CHARS,
Plugin\UrlShortenerConfigCustomizer::VALIDATE_URL,
Plugin\UrlShortenerConfigCustomizer::ENABLE_NOT_FOUND_REDIRECTION,
Plugin\UrlShortenerConfigCustomizer::NOT_FOUND_REDIRECT_TO,
'installer' => [
'enabled_options' => [
Option\Database\DatabaseDriverConfigOption::class,
Option\Database\DatabaseNameConfigOption::class,
Option\Database\DatabaseHostConfigOption::class,
Option\Database\DatabasePortConfigOption::class,
Option\Database\DatabaseUserConfigOption::class,
Option\Database\DatabasePasswordConfigOption::class,
Option\Database\DatabaseSqlitePathConfigOption::class,
Option\Database\DatabaseMySqlOptionsConfigOption::class,
Option\UrlShortener\ShortDomainHostConfigOption::class,
Option\UrlShortener\ShortDomainSchemaConfigOption::class,
Option\UrlShortener\ValidateUrlConfigOption::class,
Option\Visit\VisitsWebhooksConfigOption::class,
Option\Redirect\BaseUrlRedirectConfigOption::class,
Option\Redirect\InvalidShortUrlRedirectConfigOption::class,
Option\Redirect\Regular404RedirectConfigOption::class,
Option\DisableTrackParamConfigOption::class,
Option\Visit\CheckVisitsThresholdConfigOption::class,
Option\Visit\VisitsThresholdConfigOption::class,
Option\BasePathConfigOption::class,
Option\Worker\TaskWorkerNumConfigOption::class,
Option\Worker\WebWorkerNumConfigOption::class,
Option\RedisServersConfigOption::class,
Option\UrlShortener\ShortCodeLengthOption::class,
Option\Mercure\EnableMercureConfigOption::class,
Option\Mercure\MercurePublicUrlConfigOption::class,
Option\Mercure\MercureInternalUrlConfigOption::class,
Option\Mercure\MercureJwtSecretConfigOption::class,
Option\UrlShortener\GeoLiteLicenseKeyConfigOption::class,
Option\UrlShortener\IpAnonymizationConfigOption::class,
],
Plugin\ApplicationConfigCustomizer::class => [
Plugin\ApplicationConfigCustomizer::SECRET,
Plugin\ApplicationConfigCustomizer::DISABLE_TRACK_PARAM,
Plugin\ApplicationConfigCustomizer::CHECK_VISITS_THRESHOLD,
Plugin\ApplicationConfigCustomizer::VISITS_THRESHOLD,
Plugin\ApplicationConfigCustomizer::BASE_PATH,
],
Plugin\DatabaseConfigCustomizer::class => [
Plugin\DatabaseConfigCustomizer::DRIVER,
Plugin\DatabaseConfigCustomizer::NAME,
Plugin\DatabaseConfigCustomizer::USER,
Plugin\DatabaseConfigCustomizer::PASSWORD,
Plugin\DatabaseConfigCustomizer::HOST,
Plugin\DatabaseConfigCustomizer::PORT,
],
],
'installation_commands' => [
'db_create_schema' => [
'command' => 'bin/cli db:create',
],
'db_migrate' => [
'command' => 'bin/cli db:migrate',
'installation_commands' => [
'db_create_schema' => [
'command' => 'bin/cli db:create',
],
'db_migrate' => [
'command' => 'bin/cli db:migrate',
],
],
],

View File

@@ -1,11 +1,14 @@
<?php
declare(strict_types=1);
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Shlinkio\Shlink\Common\Cache\RedisFactory;
use Shlinkio\Shlink\Common\Lock\RetryLockStoreDelegatorFactory;
use Shlinkio\Shlink\Common\Logger\LoggerAwareDelegatorFactory;
use Symfony\Component\Lock;
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY;
return [
@@ -17,18 +20,21 @@ return [
'factories' => [
Lock\Store\FlockStore::class => ConfigAbstractFactory::class,
Lock\Store\RedisStore::class => ConfigAbstractFactory::class,
Lock\Factory::class => ConfigAbstractFactory::class,
Lock\LockFactory::class => ConfigAbstractFactory::class,
LOCAL_LOCK_FACTORY => ConfigAbstractFactory::class,
],
'aliases' => [
// With this config, a user could alias 'lock_store' => 'redis_lock_store' to override the default
'lock_store' => Lock\Store\FlockStore::class,
'lock_store' => 'local_lock_store',
'redis_lock_store' => Lock\Store\RedisStore::class,
'local_lock_store' => Lock\Store\FlockStore::class,
],
'delegators' => [
Lock\Store\RedisStore::class => [
RetryLockStoreDelegatorFactory::class,
],
Lock\Factory::class => [
Lock\LockFactory::class => [
LoggerAwareDelegatorFactory::class,
],
],
@@ -37,7 +43,8 @@ return [
ConfigAbstractFactory::class => [
Lock\Store\FlockStore::class => ['config.locks.locks_dir'],
Lock\Store\RedisStore::class => [RedisFactory::SERVICE_NAME],
Lock\Factory::class => ['lock_store'],
Lock\LockFactory::class => ['lock_store'],
LOCAL_LOCK_FACTORY => ['local_lock_store'],
],
];

View File

@@ -1,66 +1,75 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Formatter;
use Monolog\Handler;
use Monolog\Logger;
use Monolog\Processor;
use MonologFactory\DiContainerLoggerFactory;
use PhpMiddleware\RequestId;
use Psr\Log\LoggerInterface;
use const PHP_EOL;
$processors = [
'exception_with_new_line' => [
'name' => Common\Logger\Processor\ExceptionWithNewLineProcessor::class,
],
'psr3' => [
'name' => Processor\PsrLogMessageProcessor::class,
],
'request_id' => RequestId\MonologProcessor::class,
];
$formatter = [
'name' => Formatter\LineFormatter::class,
'params' => [
'format' => '[%datetime%] [%extra.request_id%] %channel%.%level_name% - %message%' . PHP_EOL,
'allow_inline_line_breaks' => true,
],
];
return [
'logger' => [
'formatters' => [
'dashed' => [
'format' => '[%datetime%] %channel%.%level_name% - %message%' . PHP_EOL,
'include_stacktraces' => true,
'Shlink' => [
'name' => 'Shlink',
'handlers' => [
'shlink_handler' => [
'name' => Handler\RotatingFileHandler::class,
'params' => [
'level' => Logger::INFO,
'filename' => 'data/log/shlink_log.log',
'max_files' => 30,
'file_permission' => 0666,
],
'formatter' => $formatter,
],
],
'processors' => $processors,
],
'handlers' => [
'shlink_rotating_handler' => [
'class' => RotatingFileHandler::class,
'level' => Logger::INFO,
'filename' => 'data/log/shlink_log.log',
'max_files' => 30,
'formatter' => 'dashed',
],
'access_handler' => [
'class' => StreamHandler::class,
'level' => Logger::INFO,
'stream' => 'php://stdout',
],
],
'processors' => [
'exception_with_new_line' => [
'class' => Common\Logger\Processor\ExceptionWithNewLineProcessor::class,
],
'psr3' => [
'class' => Processor\PsrLogMessageProcessor::class,
],
],
'loggers' => [
'Shlink' => [
'handlers' => ['shlink_rotating_handler'],
'processors' => ['exception_with_new_line', 'psr3'],
],
'Access' => [
'handlers' => ['access_handler'],
'processors' => ['exception_with_new_line', 'psr3'],
'Access' => [
'name' => 'Access',
'handlers' => [
'access_handler' => [
'name' => Handler\StreamHandler::class,
'params' => [
'level' => Logger::INFO,
'stream' => 'php://stdout',
],
'formatter' => $formatter,
],
],
'processors' => $processors,
],
],
'dependencies' => [
'factories' => [
'Logger_Shlink' => Common\Logger\LoggerFactory::class,
'Logger_Access' => Common\Logger\LoggerFactory::class,
'Logger_Shlink' => [DiContainerLoggerFactory::class, 'Shlink'],
'Logger_Access' => [DiContainerLoggerFactory::class, 'Access'],
],
'aliases' => [
'logger' => 'Logger_Shlink',
@@ -69,10 +78,11 @@ return [
],
],
'zend-expressive-swoole' => [
'mezzio-swoole' => [
'swoole-http-server' => [
'logger' => [
'logger-name' => 'Logger_Access',
'format' => '%h %l %u "%r" %>s %b',
],
],
],

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
use Monolog\Handler\StreamHandler;
@@ -7,34 +8,28 @@ use Monolog\Logger;
$isSwoole = extension_loaded('swoole');
// For swoole, send logs to standard output
$logger = $isSwoole ? [
'handlers' => [
'shlink_rotating_handler' => [
'level' => Logger::EMERGENCY, // This basically disables regular file logs
],
'shlink_stdout_handler' => [
'class' => StreamHandler::class,
$handler = $isSwoole
? [
'name' => StreamHandler::class,
'params' => [
'level' => Logger::DEBUG,
'stream' => 'php://stdout',
'formatter' => 'dashed',
],
],
'loggers' => [
'Shlink' => [
'handlers' => ['shlink_stdout_handler'],
],
],
] : [
'handlers' => [
'shlink_rotating_handler' => [
]
: [
'params' => [
'level' => Logger::DEBUG,
],
],
];
];
return [
'logger' => $logger,
'logger' => [
'Shlink' => [
'handlers' => [
'shlink_handler' => $handler,
],
],
],
];

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Laminas\ServiceManager\Proxy\LazyServiceFactory;
use Shlinkio\Shlink\Common\Mercure\LcobucciJwtProvider;
use Symfony\Component\Mercure\Publisher;
use Symfony\Component\Mercure\PublisherInterface;
return [
'mercure' => [
'public_hub_url' => null,
'internal_hub_url' => null,
'jwt_secret' => null,
'jwt_issuer' => 'Shlink',
],
'dependencies' => [
'delegators' => [
LcobucciJwtProvider::class => [
LazyServiceFactory::class,
],
Publisher::class => [
LazyServiceFactory::class,
],
],
'lazy_services' => [
'class_map' => [
LcobucciJwtProvider::class => LcobucciJwtProvider::class,
Publisher::class => PublisherInterface::class,
],
],
],
];

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
return [
'mercure' => [
'public_hub_url' => 'http://localhost:8001',
'internal_hub_url' => 'http://shlink_mercure_proxy',
'jwt_secret' => 'mercure_jwt_key',
],
];

View File

@@ -1,55 +1,73 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink;
use Zend\Expressive;
use Zend\Stratigility\Middleware\ErrorHandler;
use Laminas\Stratigility\Middleware\ErrorHandler;
use Mezzio\Helper;
use Mezzio\ProblemDetails;
use Mezzio\Router;
use PhpMiddleware\RequestId\RequestIdMiddleware;
return [
'middleware_pipeline' => [
'pre-routing' => [
'error-handler' => [
'middleware' => [
Helper\ContentLengthMiddleware::class,
ErrorHandler::class,
Expressive\Helper\ContentLengthMiddleware::class,
Common\Middleware\CloseDbConnectionMiddleware::class,
],
'priority' => 12,
],
'pre-routing-rest' => [
'error-handler-rest' => [
'path' => '/rest',
'middleware' => [
Rest\Middleware\PathVersionMiddleware::class,
Rest\Middleware\ShortUrl\ShortCodePathMiddleware::class,
Rest\Middleware\CrossDomainMiddleware::class,
RequestIdMiddleware::class,
ProblemDetails\ProblemDetailsMiddleware::class,
],
],
'pre-routing' => [
'middleware' => [
Common\Middleware\CloseDbConnectionMiddleware::class,
],
'priority' => 11,
],
'routing' => [
'middleware' => [
Expressive\Router\Middleware\RouteMiddleware::class,
Router\Middleware\RouteMiddleware::class,
Router\Middleware\ImplicitHeadMiddleware::class,
],
'priority' => 10,
],
'rest' => [
'path' => '/rest',
'middleware' => [
Rest\Middleware\CrossDomainMiddleware::class,
Expressive\Router\Middleware\ImplicitOptionsMiddleware::class,
Router\Middleware\ImplicitOptionsMiddleware::class,
Rest\Middleware\BodyParserMiddleware::class,
Rest\Middleware\AuthenticationMiddleware::class,
],
'priority' => 5,
],
'post-routing' => [
'dispatch' => [
'middleware' => [
Expressive\Router\Middleware\DispatchMiddleware::class,
Core\Response\NotFoundHandler::class,
Router\Middleware\DispatchMiddleware::class,
],
],
'not-found-rest' => [
'path' => '/rest',
'middleware' => [
ProblemDetails\ProblemDetailsNotFoundHandler::class,
],
],
'not-found' => [
'middleware' => [
Core\ErrorHandler\NotFoundRedirectHandler::class,
Core\ErrorHandler\NotFoundTemplateHandler::class,
],
'priority' => 1,
],
],
];

View File

@@ -1,11 +0,0 @@
<?php
declare(strict_types=1);
/** @deprecated */
return [
'preview_generation' => [
'files_location' => 'data/cache',
],
];

View File

@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);
return [
'not_found_redirects' => [
'invalid_short_url' => null, // Formerly url_shortener.not_found_short_url.redirect_to
'regular_404' => null,
'base_url' => null,
],
];

View File

@@ -1,13 +1,16 @@
<?php
declare(strict_types=1);
return [
'redis' => [
'servers' => 'tcp://shlink_redis:6379',
// 'servers' => [
// 'tcp://shlink_redis:6379',
// ],
'cache' => [
'redis' => [
'servers' => 'tcp://shlink_redis:6379',
// 'servers' => [
// 'tcp://shlink_redis:6379',
// ],
],
],
'dependencies' => [

View File

@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Laminas\ServiceManager\Factory\InvokableFactory;
use PhpMiddleware\RequestId;
return [
'request_id' => [
'allow_override' => true,
'header_name' => 'X-Request-Id',
],
'dependencies' => [
'factories' => [
RequestId\Generator\RamseyUuid4StaticGenerator::class => InvokableFactory::class,
RequestId\RequestIdProviderFactory::class => ConfigAbstractFactory::class,
RequestId\RequestIdMiddleware::class => ConfigAbstractFactory::class,
RequestId\MonologProcessor::class => ConfigAbstractFactory::class,
],
],
ConfigAbstractFactory::class => [
RequestId\RequestIdProviderFactory::class => [
RequestId\Generator\RamseyUuid4StaticGenerator::class,
'config.request_id.allow_override',
'config.request_id.header_name',
],
RequestId\RequestIdMiddleware::class => [
RequestId\RequestIdProviderFactory::class,
'config.request_id.header_name',
],
RequestId\MonologProcessor::class => [RequestId\RequestIdMiddleware::class],
],
];

View File

@@ -1,7 +1,8 @@
<?php
declare(strict_types=1);
use Zend\Expressive\Router\FastRouteRouter;
use Mezzio\Router\FastRouteRouter;
return [

View File

@@ -1,9 +1,13 @@
<?php
use Zend\Expressive\Router\FastRouteRouter;
declare(strict_types=1);
use Mezzio\Router\FastRouteRouter;
return [
'router' => [
// 'base_path' => '',
'fastroute' => [
FastRouteRouter::CONFIG_CACHE_ENABLED => false,
],

View File

@@ -1,10 +1,12 @@
<?php
declare(strict_types=1);
return [
'zend-expressive-swoole' => [
'enable_coroutine' => true,
'mezzio-swoole' => [
// Setting this to true can have unexpected behaviors when running several concurrent slow DB queries
'enable_coroutine' => false,
'swoole-http-server' => [
'host' => '0.0.0.0',

View File

@@ -1,12 +1,13 @@
<?php
declare(strict_types=1);
use Zend\Expressive\Swoole\HotCodeReload\FileWatcher\InotifyFileWatcher;
use Zend\ServiceManager\Factory\InvokableFactory;
use Laminas\ServiceManager\Factory\InvokableFactory;
use Mezzio\Swoole\HotCodeReload\FileWatcher\InotifyFileWatcher;
return [
'zend-expressive-swoole' => [
'mezzio-swoole' => [
'hot-code-reload' => [
'enable' => true,
],

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
return [

View File

@@ -1,23 +1,20 @@
<?php
declare(strict_types=1);
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
use function Shlinkio\Shlink\Common\env;
use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH;
return [
'url_shortener' => [
'domain' => [
'schema' => env('SHORTENED_URL_SCHEMA', 'http'),
'hostname' => env('SHORTENED_URL_HOSTNAME'),
],
'shortcode_chars' => env('SHORTCODE_CHARS', UrlShortenerOptions::DEFAULT_CHARS),
'validate_url' => true,
'not_found_short_url' => [
'enable_redirection' => false,
'redirect_to' => null,
'schema' => 'https',
'hostname' => '',
],
'validate_url' => false,
'anonymize_remote_addr' => true,
'visits_webhooks' => [],
'default_short_codes_length' => DEFAULT_SHORT_CODES_LENGTH,
],
];

View File

@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
return [
'url_shortener' => [
'domain' => [
'schema' => 'http',
'hostname' => 'localhost:8080',
],
],
];

View File

@@ -1,13 +0,0 @@
<?php
declare(strict_types=1);
return [
'wkhtmltopdf' => [
'images' => [
'binary' => __DIR__ . '/../../bin/wkhtmltoimage',
'type' => 'jpg',
],
],
];

View File

@@ -1,13 +1,16 @@
<?php
declare(strict_types=1);
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Laminas\ServiceManager\ServiceManager;
use Psr\Container\ContainerInterface;
use Zend\ServiceManager\ServiceManager;
/** @var ContainerInterface|ServiceManager $container */
$container = include __DIR__ . '/container.php';
$em = $container->get(EntityManager::class);
return (function () {
/** @var ContainerInterface|ServiceManager $container */
$container = include __DIR__ . '/container.php';
$em = $container->get(EntityManager::class);
return ConsoleRunner::createHelperSet($em);
return ConsoleRunner::createHelperSet($em);
})();

View File

@@ -1,33 +1,35 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink;
use Acelaya\ExpressiveErrorHandler;
use Zend\ConfigAggregator;
use Zend\Expressive;
use Laminas\ConfigAggregator;
use Mezzio;
use Mezzio\ProblemDetails;
use function Shlinkio\Shlink\Common\env;
return (new ConfigAggregator\ConfigAggregator([
Expressive\ConfigProvider::class,
Expressive\Router\ConfigProvider::class,
Expressive\Router\FastRouteRouter\ConfigProvider::class,
Expressive\Plates\ConfigProvider::class,
Expressive\Swoole\ConfigProvider::class,
ExpressiveErrorHandler\ConfigProvider::class,
Mezzio\ConfigProvider::class,
Mezzio\Router\ConfigProvider::class,
Mezzio\Router\FastRouteRouter\ConfigProvider::class,
Mezzio\Plates\ConfigProvider::class,
Mezzio\Swoole\ConfigProvider::class,
ProblemDetails\ConfigProvider::class,
Common\ConfigProvider::class,
Config\ConfigProvider::class,
IpGeolocation\ConfigProvider::class,
EventDispatcher\ConfigProvider::class,
Core\ConfigProvider::class,
CLI\ConfigProvider::class,
Rest\ConfigProvider::class,
EventDispatcher\ConfigProvider::class,
PreviewGenerator\ConfigProvider::class,
new ConfigAggregator\PhpFileProvider('config/autoload/{{,*.}global,{,*.}local}.php'),
env('APP_ENV') === 'test'
? new ConfigAggregator\PhpFileProvider('config/test/*.global.php')
: new ConfigAggregator\ZendConfigProvider('config/params/{generated_config.php,*.config.{php,json}}'),
: new ConfigAggregator\LaminasConfigProvider('config/params/{generated_config.php,*.config.{php,json}}'),
], 'data/cache/app_config.php', [
Core\Config\SimplifiedConfigParser::class,
Core\Config\BasePathPrefixer::class,
Core\Config\DeprecatedConfigParser::class,
]))->getMergedConfig();

View File

@@ -1,23 +1,27 @@
<?php
declare(strict_types=1);
use Symfony\Component\Dotenv\Dotenv;
use Zend\ServiceManager\ServiceManager;
use Laminas\ServiceManager\ServiceManager;
use Symfony\Component\Lock;
use const Shlinkio\Shlink\Core\LOCAL_LOCK_FACTORY;
chdir(dirname(__DIR__));
require 'vendor/autoload.php';
// If the Dotenv class exists, load env vars and enable errors
if (class_exists(Dotenv::class)) {
error_reporting(E_ALL);
ini_set('display_errors', '1');
$dotenv = new Dotenv();
$dotenv->load(__DIR__ . '/../.env');
// This class alias tricks the ConfigAbstractFactory to return Lock\Factory instances even with a different service name
// It needs to be placed here as individual config files will not be loaded once config is cached
if (! class_exists(LOCAL_LOCK_FACTORY)) {
class_alias(Lock\LockFactory::class, LOCAL_LOCK_FACTORY);
}
// Build container
$config = require __DIR__ . '/config.php';
$container = new ServiceManager($config['dependencies']);
$container->setService('config', $config);
return $container;
return (function () {
$config = require __DIR__ . '/config.php';
$container = new ServiceManager($config['dependencies']);
$container->setService('config', $config);
return $container;
})();

15
config/run.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
use Mezzio\Application;
use Psr\Container\ContainerInterface;
use Symfony\Component\Console\Application as CliApp;
return function (bool $isCli = false): void {
/** @var ContainerInterface $container */
$container = include __DIR__ . '/container.php';
$app = $container->get($isCli ? CliApp::class : Application::class);
$app->run();
};

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\TestUtils;
@@ -6,14 +7,6 @@ namespace Shlinkio\Shlink\TestUtils;
use Doctrine\ORM\EntityManager;
use Psr\Container\ContainerInterface;
use function file_exists;
use function touch;
// Create an empty .env file
if (! file_exists('.env')) {
touch('.env');
}
/** @var ContainerInterface $container */
$container = require __DIR__ . '/../container.php';
$testHelper = $container->get(Helper\TestHelper::class);
@@ -22,6 +15,4 @@ $em = $container->get(EntityManager::class);
$testHelper->createTestDb();
ApiTest\ApiTestCase::setApiClient($container->get('shlink_test_api_client'));
ApiTest\ApiTestCase::setSeedFixturesCallback(function () use ($testHelper, $em, $config) {
$testHelper->seedFixtures($em, $config['data_fixtures'] ?? []);
});
ApiTest\ApiTestCase::setSeedFixturesCallback(fn () => $testHelper->seedFixtures($em, $config['data_fixtures'] ?? []));

View File

@@ -1,18 +1,11 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink\TestUtils;
use Psr\Container\ContainerInterface;
use function file_exists;
use function touch;
// Create an empty .env file
if (! file_exists('.env')) {
touch('.env');
}
/** @var ContainerInterface $container */
$container = require __DIR__ . '/../container.php';
$container->get(Helper\TestHelper::class)->createTestDb();

View File

@@ -1,12 +1,13 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink;
use GuzzleHttp\Client;
use Laminas\ConfigAggregator\ConfigAggregator;
use Laminas\ServiceManager\Factory\InvokableFactory;
use PDO;
use Zend\ConfigAggregator\ConfigAggregator;
use Zend\ServiceManager\Factory\InvokableFactory;
use function Shlinkio\Shlink\Common\env;
use function sprintf;
@@ -15,40 +16,50 @@ use function sys_get_temp_dir;
$swooleTestingHost = '127.0.0.1';
$swooleTestingPort = 9999;
$buildDbConnection = function () {
$buildDbConnection = function (): array {
$driver = env('DB_DRIVER', 'sqlite');
$isCi = env('TRAVIS', false);
$getMysqlHost = fn (string $driver) => sprintf('shlink_db%s', $driver === 'mysql' ? '' : '_maria');
$getCiMysqlPort = fn (string $driver) => $driver === 'mysql' ? '3307' : '3308';
switch ($driver) {
case 'sqlite':
return [
'driver' => 'pdo_sqlite',
'path' => sys_get_temp_dir() . '/shlink-tests.db',
];
case 'mysql':
return [
'driver' => 'pdo_mysql',
'host' => $isCi ? '127.0.0.1' : 'shlink_db',
'user' => 'root',
'password' => $isCi ? '' : 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
'driverOptions' => [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
],
];
case 'postgres':
return [
'driver' => 'pdo_pgsql',
'host' => $isCi ? '127.0.0.1' : 'shlink_db_postgres',
'user' => 'postgres',
'password' => $isCi ? '' : 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
];
default:
return [];
}
$driverConfigMap = [
'sqlite' => [
'driver' => 'pdo_sqlite',
'path' => sys_get_temp_dir() . '/shlink-tests.db',
],
'mysql' => [
'driver' => 'pdo_mysql',
'host' => $isCi ? '127.0.0.1' : $getMysqlHost($driver),
'port' => $isCi ? $getCiMysqlPort($driver) : '3306',
'user' => 'root',
'password' => 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
'driverOptions' => [
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
],
],
'postgres' => [
'driver' => 'pdo_pgsql',
'host' => $isCi ? '127.0.0.1' : 'shlink_db_postgres',
'port' => $isCi ? '5433' : '5432',
'user' => 'postgres',
'password' => 'root',
'dbname' => 'shlink_test',
'charset' => 'utf8',
],
'mssql' => [
'driver' => 'pdo_sqlsrv',
'host' => $isCi ? '127.0.0.1' : 'shlink_db_ms',
'user' => 'sa',
'password' => 'Passw0rd!',
'dbname' => 'shlink_test',
],
];
$driverConfigMap['maria'] = $driverConfigMap['mysql'];
return $driverConfigMap[$driver] ?? [];
};
return [
@@ -61,21 +72,28 @@ return [
'schema' => 'http',
'hostname' => 'doma.in',
],
'validate_url' => true,
],
'zend-expressive-swoole' => [
'mezzio-swoole' => [
'enable_coroutine' => false,
'swoole-http-server' => [
'host' => $swooleTestingHost,
'port' => $swooleTestingPort,
'process-name' => 'shlink_test',
'options' => [
'pid_file' => sys_get_temp_dir() . '/shlink-test-swoole.pid',
'worker_num' => 1,
'task_worker_num' => 1,
'enable_coroutine' => false,
],
],
],
'mercure' => [
'public_hub_url' => null,
'internal_hub_url' => null,
'jwt_secret' => null,
],
'dependencies' => [
'services' => [
'shlink_test_api_client' => new Client([

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -ex
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
apt-get update
ACCEPT_EULA=Y apt-get install msodbcsql17
apt-get install unixodbc-dev

2
data/infra/database_maria/.gitignore vendored Executable file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

View File

@@ -11,7 +11,7 @@ server {
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}

View File

@@ -8,7 +8,7 @@
# Description: Shlink non-blocking server with swoole
### END INIT INFO
SCRIPT=/path/to/shlink/vendor/bin/zend-expressive-swoole\ start
SCRIPT=/path/to/shlink/vendor/bin/mezzio-swoole\ start
RUNAS=root
PIDFILE=/var/run/shlink_swoole.pid

View File

@@ -0,0 +1,17 @@
server {
listen 80 default_server;
error_log /home/shlink/www/data/infra/nginx/mercure_proxy.error.log;
location / {
proxy_pass http://shlink_mercure;
proxy_read_timeout 24h;
proxy_http_version 1.1;
proxy_set_header Connection "";
## Be sure to set USE_FORWARDED_HEADERS=1 to allow the hub to use those headers ##
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

View File

@@ -1,29 +1,31 @@
FROM php:7.3.1-fpm-alpine3.8
FROM php:7.4.5-fpm-alpine3.11
MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
ENV APCU_VERSION 5.1.16
ENV APCU_BC_VERSION 1.0.4
ENV XDEBUG_VERSION "2.7.0RC1"
ENV APCU_VERSION 5.1.18
ENV APCU_BC_VERSION 1.0.5
ENV XDEBUG_VERSION 2.9.0
RUN apk update
# Install common php extensions
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install iconv
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install calendar
RUN apk add --no-cache --virtual sqlite-libs
RUN apk add --no-cache --virtual sqlite-dev
RUN apk add --no-cache oniguruma-dev
RUN docker-php-ext-install mbstring
RUN apk add --no-cache sqlite-libs
RUN apk add --no-cache sqlite-dev
RUN docker-php-ext-install pdo_sqlite
RUN apk add --no-cache --virtual icu-dev
RUN apk add --no-cache icu-dev
RUN docker-php-ext-install intl
RUN apk add --no-cache --virtual libzip-dev zlib-dev
RUN apk add --no-cache libzip-dev zlib-dev
RUN docker-php-ext-install zip
RUN apk add --no-cache --virtual libpng-dev
RUN apk add --no-cache libpng-dev
RUN docker-php-ext-install gd
RUN apk add --no-cache postgresql-dev
@@ -63,6 +65,15 @@ RUN docker-php-ext-configure xdebug\
# cleanup
RUN rm /tmp/xdebug.tar.gz
# Install sqlsrv driver
RUN wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.1.1-1_amd64.apk && \
apk add --allow-untrusted msodbcsql17_17.5.1.1-1_amd64.apk && \
apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS unixodbc-dev && \
pecl install pdo_sqlsrv && \
docker-php-ext-enable pdo_sqlsrv && \
apk del .phpize-deps && \
rm msodbcsql17_17.5.1.1-1_amd64.apk
# Install composer
RUN php -r "readfile('https://getcomposer.org/installer');" | php
RUN chmod +x composer.phar

View File

@@ -1 +1,6 @@
date.timezone = Europe/Madrid
display_errors=On
error_reporting=-1
memory_limit=-1
log_errors_max_len=0
zend.assertions=1
assert.exception=1

View File

@@ -1,29 +1,32 @@
FROM php:7.3.1-cli-alpine3.8
FROM php:7.4.5-alpine3.11
MAINTAINER Alejandro Celaya <alejandro@alejandrocelaya.com>
ENV APCU_VERSION 5.1.16
ENV APCU_BC_VERSION 1.0.4
ENV APCU_VERSION 5.1.18
ENV APCU_BC_VERSION 1.0.5
ENV INOTIFY_VERSION 2.0.0
ENV SWOOLE_VERSION 4.4.18
RUN apk update
# Install common php extensions
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install iconv
RUN docker-php-ext-install mbstring
RUN docker-php-ext-install calendar
RUN apk add --no-cache --virtual sqlite-libs
RUN apk add --no-cache --virtual sqlite-dev
RUN apk add --no-cache oniguruma-dev
RUN docker-php-ext-install mbstring
RUN apk add --no-cache sqlite-libs
RUN apk add --no-cache sqlite-dev
RUN docker-php-ext-install pdo_sqlite
RUN apk add --no-cache --virtual icu-dev
RUN apk add --no-cache icu-dev
RUN docker-php-ext-install intl
RUN apk add --no-cache --virtual libzip-dev zlib-dev
RUN apk add --no-cache libzip-dev zlib-dev
RUN docker-php-ext-install zip
RUN apk add --no-cache --virtual libpng-dev
RUN apk add --no-cache libpng-dev
RUN docker-php-ext-install gd
RUN apk add --no-cache postgresql-dev
@@ -63,12 +66,14 @@ RUN docker-php-ext-configure inotify\
# cleanup
RUN rm /tmp/inotify.tar.gz
# Install swoole
# First line fixes an error when installing pecl extensions. Found in https://github.com/docker-library/php/issues/233
RUN apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS && \
pecl install swoole && \
docker-php-ext-enable swoole && \
apk del .phpize-deps
# Install swoole and mssql driver
RUN wget https://download.microsoft.com/download/e/4/e/e4e67866-dffd-428c-aac7-8d28ddafb39b/msodbcsql17_17.5.1.1-1_amd64.apk && \
apk add --allow-untrusted msodbcsql17_17.5.1.1-1_amd64.apk && \
apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS unixodbc-dev && \
pecl install swoole-${SWOOLE_VERSION} pdo_sqlsrv && \
docker-php-ext-enable swoole pdo_sqlsrv && \
apk del .phpize-deps && \
rm msodbcsql17_17.5.1.1-1_amd64.apk
# Install composer
RUN php -r "readfile('https://getcomposer.org/installer');" | php
@@ -89,4 +94,4 @@ CMD \
if [[ ! -d "./vendor" ]]; then /usr/local/bin/composer install ; fi && \
# When restarting the container, swoole might think it is already in execution
# This forces the app to be started every second until the exit code is 0
until php ./vendor/bin/zend-expressive-swoole start; do sleep 1 ; done
until php ./vendor/bin/mezzio-swoole start; do sleep 1 ; done

View File

@@ -0,0 +1,14 @@
server {
listen 80 default_server;
error_log /home/shlink/www/data/infra/nginx/swoole_proxy.error.log;
location / {
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://shlink_swoole:8080;
proxy_read_timeout 90s;
}
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;

View File

@@ -1,10 +1,11 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
/**
@@ -29,12 +30,12 @@ class Version20160820191203 extends AbstractMigration
private function createTagsTable(Schema $schema): void
{
$table = $schema->createTable('tags');
$table->addColumn('id', Type::BIGINT, [
$table->addColumn('id', Types::BIGINT, [
'unsigned' => true,
'autoincrement' => true,
'notnull' => true,
]);
$table->addColumn('name', Type::STRING, [
$table->addColumn('name', Types::STRING, [
'length' => 255,
'notnull' => true,
]);
@@ -46,11 +47,11 @@ class Version20160820191203 extends AbstractMigration
private function createShortUrlsInTagsTable(Schema $schema): void
{
$table = $schema->createTable('short_urls_in_tags');
$table->addColumn('short_url_id', Type::BIGINT, [
$table->addColumn('short_url_id', Types::BIGINT, [
'unsigned' => true,
'notnull' => true,
]);
$table->addColumn('tag_id', Type::BIGINT, [
$table->addColumn('tag_id', Types::BIGINT, [
'unsigned' => true,
'notnull' => true,
]);

View File

@@ -1,11 +1,12 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
/**
@@ -23,10 +24,10 @@ class Version20171021093246 extends AbstractMigration
return;
}
$shortUrls->addColumn('valid_since', Type::DATETIME, [
$shortUrls->addColumn('valid_since', Types::DATETIME, [
'notnull' => false,
]);
$shortUrls->addColumn('valid_until', Type::DATETIME, [
$shortUrls->addColumn('valid_until', Types::DATETIME, [
'notnull' => false,
]);
}

View File

@@ -1,11 +1,12 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
/**
@@ -23,7 +24,7 @@ class Version20171022064541 extends AbstractMigration
return;
}
$shortUrls->addColumn('max_visits', Type::INTEGER, [
$shortUrls->addColumn('max_visits', Types::INTEGER, [
'unsigned' => true,
'notnull' => false,
]);

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
@@ -16,7 +17,6 @@ final class Version20180801183328 extends AbstractMigration
private const OLD_SIZE = 10;
/**
* @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema): void
@@ -25,7 +25,6 @@ final class Version20180801183328 extends AbstractMigration
}
/**
* @param Schema $schema
* @throws SchemaException
*/
public function down(Schema $schema): void
@@ -34,8 +33,6 @@ final class Version20180801183328 extends AbstractMigration
}
/**
* @param Schema $schema
* @param int $size
* @throws SchemaException
*/
private function setSize(Schema $schema, int $size): void

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
@@ -16,7 +17,6 @@ use Shlinkio\Shlink\Common\Util\IpAddress;
final class Version20180913205455 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema): void
{
@@ -24,7 +24,6 @@ final class Version20180913205455 extends AbstractMigration
}
/**
* @param Schema $schema
* @throws DBALException
*/
public function postUp(Schema $schema): void
@@ -66,7 +65,6 @@ final class Version20180913205455 extends AbstractMigration
}
/**
* @param Schema $schema
*/
public function down(Schema $schema): void
{

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
@@ -18,7 +19,6 @@ final class Version20180915110857 extends AbstractMigration
];
/**
* @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema): void
@@ -38,7 +38,7 @@ final class Version20180915110857 extends AbstractMigration
[
'onDelete' => self::ON_DELETE_MAP[$foreignTable],
'onUpdate' => 'RESTRICT',
]
],
);
}
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
@@ -7,7 +8,7 @@ use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
/**
@@ -23,7 +24,6 @@ final class Version20181020060559 extends AbstractMigration
];
/**
* @param Schema $schema
* @throws SchemaException
*/
public function up(Schema $schema): void
@@ -35,7 +35,7 @@ final class Version20181020060559 extends AbstractMigration
{
foreach ($columnNames as $name) {
if (! $visitLocations->hasColumn($name)) {
$visitLocations->addColumn($name, Type::STRING, ['notnull' => false]);
$visitLocations->addColumn($name, Types::STRING, ['notnull' => false]);
}
}
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;

View File

@@ -1,11 +1,12 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20190930165521 extends AbstractMigration
@@ -21,19 +22,19 @@ final class Version20190930165521 extends AbstractMigration
}
$domains = $schema->createTable('domains');
$domains->addColumn('id', Type::BIGINT, [
$domains->addColumn('id', Types::BIGINT, [
'unsigned' => true,
'autoincrement' => true,
'notnull' => true,
]);
$domains->addColumn('authority', Type::STRING, [
$domains->addColumn('authority', Types::STRING, [
'length' => 512,
'notnull' => true,
]);
$domains->addUniqueIndex(['authority']);
$domains->setPrimaryKey(['id']);
$shortUrls->addColumn('domain_id', Type::BIGINT, [
$shortUrls->addColumn('domain_id', Types::BIGINT, [
'unsigned' => true,
'notnull' => false,
]);

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;

View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\SchemaException;
use Doctrine\Migrations\AbstractMigration;
final class Version20191020074522 extends AbstractMigration
{
/**
* @throws SchemaException
*/
public function up(Schema $schema): void
{
$this->getOriginalUrlColumn($schema)->setLength(2048);
}
/**
* @throws SchemaException
*/
public function down(Schema $schema): void
{
$this->getOriginalUrlColumn($schema)->setLength(1024);
}
/**
* @throws SchemaException
*/
private function getOriginalUrlColumn(Schema $schema): Column
{
return $schema->getTable('short_urls')->getColumn('original_url');
}
}

View File

@@ -0,0 +1,96 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
use function Functional\some;
final class Version20200105165647 extends AbstractMigration
{
private const COLUMNS = ['lat' => 'latitude', 'lon' => 'longitude'];
/**
* @throws DBALException
*/
public function preUp(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
$this->skipIf(some(
self::COLUMNS,
fn (string $v, string $newColName) => $visitLocations->hasColumn($newColName),
), 'New columns already exist');
foreach (self::COLUMNS as $columnName) {
$qb = $this->connection->createQueryBuilder();
$qb->update('visit_locations')
->set($columnName, ':zeroValue')
->where($qb->expr()->orX(
$qb->expr()->eq($columnName, ':emptyString'),
$qb->expr()->isNull($columnName),
))
->setParameters([
'zeroValue' => '0',
'emptyString' => '',
])
->execute();
}
}
/**
* @throws DBALException
*/
public function up(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
foreach (self::COLUMNS as $newName => $oldName) {
$visitLocations->addColumn($newName, Types::FLOAT, [
'default' => '0.0',
]);
}
}
/**
* @throws DBALException
*/
public function postUp(Schema $schema): void
{
$platformName = $this->connection->getDatabasePlatform()->getName();
$castType = $platformName === 'postgres' ? 'DOUBLE PRECISION' : 'DECIMAL(9,2)';
foreach (self::COLUMNS as $newName => $oldName) {
$qb = $this->connection->createQueryBuilder();
$qb->update('visit_locations')
->set($newName, 'CAST(' . $oldName . ' AS ' . $castType . ')')
->execute();
}
}
public function preDown(Schema $schema): void
{
foreach (self::COLUMNS as $newName => $oldName) {
$qb = $this->connection->createQueryBuilder();
$qb->update('visit_locations')
->set($oldName, $newName)
->execute();
}
}
/**
* @throws DBALException
*/
public function down(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
foreach (self::COLUMNS as $colName => $oldName) {
$visitLocations->dropColumn($colName);
}
}
}

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
use function Functional\none;
final class Version20200106215144 extends AbstractMigration
{
private const COLUMNS = ['latitude', 'longitude'];
/**
* @throws DBALException
*/
public function up(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
$this->skipIf(none(
self::COLUMNS,
fn (string $oldColName) => $visitLocations->hasColumn($oldColName),
), 'Old columns do not exist');
foreach (self::COLUMNS as $colName) {
$visitLocations->dropColumn($colName);
}
}
/**
* @throws DBALException
*/
public function down(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
foreach (self::COLUMNS as $colName) {
$visitLocations->addColumn($colName, Types::STRING, [
'notnull' => false,
]);
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use function Functional\each;
use function Functional\partial_left;
final class Version20200110182849 extends AbstractMigration
{
private const DEFAULT_EMPTY_VALUE = '';
private const COLUMN_DEFAULTS_MAP = [
'visits' => [
'referer',
'user_agent',
],
'visit_locations' => [
'timezone',
'country_code',
'country_name',
'region_name',
'city_name',
],
];
public function up(Schema $schema): void
{
each(
self::COLUMN_DEFAULTS_MAP,
fn (array $columns, string $tableName) =>
each($columns, partial_left([$this, 'setDefaultValueForColumnInTable'], $tableName)),
);
}
public function setDefaultValueForColumnInTable(string $tableName, string $columnName): void
{
$qb = $this->connection->createQueryBuilder();
$qb->update($tableName)
->set($columnName, ':emptyValue')
->setParameter('emptyValue', self::DEFAULT_EMPTY_VALUE)
->where($qb->expr()->isNull($columnName))
->execute();
}
public function down(Schema $schema): void
{
// No need (and no way) to undo this migration
}
}

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20200323190014 extends AbstractMigration
{
public function up(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
$this->skipIf($visitLocations->hasColumn('is_empty'));
$visitLocations->addColumn('is_empty', Types::BOOLEAN, ['default' => false]);
}
public function postUp(Schema $schema): void
{
$qb = $this->connection->createQueryBuilder();
$qb->update('visit_locations')
->set('is_empty', ':isEmpty')
->where($qb->expr()->eq('country_code', ':emptyString'))
->andWhere($qb->expr()->eq('country_name', ':emptyString'))
->andWhere($qb->expr()->eq('region_name', ':emptyString'))
->andWhere($qb->expr()->eq('city_name', ':emptyString'))
->andWhere($qb->expr()->eq('timezone', ':emptyString'))
->andWhere($qb->expr()->eq('lat', 0))
->andWhere($qb->expr()->eq('lon', 0))
->setParameter('isEmpty', true)
->setParameter('emptyString', '')
->execute();
}
public function down(Schema $schema): void
{
$visitLocations = $schema->getTable('visit_locations');
$this->skipIf(!$visitLocations->hasColumn('is_empty'));
$visitLocations->dropColumn('is_empty');
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace ShlinkMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20200503170404 extends AbstractMigration
{
private const INDEX_NAME = 'IDX_visits_date';
public function up(Schema $schema): void
{
$visits = $schema->getTable('visits');
$this->skipIf($visits->hasIndex(self::INDEX_NAME));
$visits->addIndex(['date'], self::INDEX_NAME);
}
public function down(Schema $schema): void
{
$visits = $schema->getTable('visits');
$this->skipIf(! $visits->hasIndex(self::INDEX_NAME));
$visits->dropIndex(self::INDEX_NAME);
}
}

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace <namespace>;

14
docker-compose.ci.yml Normal file
View File

@@ -0,0 +1,14 @@
version: '3'
services:
shlink_db:
environment:
MYSQL_DATABASE: shlink_test
shlink_db_postgres:
environment:
POSTGRES_DB: shlink_test
shlink_db_maria:
environment:
MYSQL_DATABASE: shlink_test

View File

@@ -24,3 +24,9 @@ services:
volumes:
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro
shlink_db_maria:
user: 1000:1000
volumes:
- /etc/passwd:/etc/passwd:ro
- /etc/group:/etc/group:ro

View File

@@ -3,7 +3,7 @@ version: '3'
services:
shlink_nginx:
container_name: shlink_nginx
image: nginx:1.15.9-alpine
image: nginx:1.17.10-alpine
ports:
- "8000:80"
volumes:
@@ -24,7 +24,24 @@ services:
links:
- shlink_db
- shlink_db_postgres
- shlink_db_maria
- shlink_db_ms
- shlink_redis
- shlink_mercure
- shlink_mercure_proxy
environment:
LC_ALL: C
shlink_swoole_proxy:
container_name: shlink_swoole_proxy
image: nginx:1.17.10-alpine
ports:
- "8002:80"
volumes:
- ./:/home/shlink/www
- ./data/infra/swoole_proxy_vhost.conf:/etc/nginx/conf.d/default.conf
links:
- shlink_swoole
shlink_swoole:
container_name: shlink_swoole
@@ -33,12 +50,20 @@ services:
dockerfile: ./data/infra/swoole.Dockerfile
ports:
- "8080:8080"
- "9001:9001"
volumes:
- ./:/home/shlink
- ./data/infra/php.ini:/usr/local/etc/php/php.ini
links:
- shlink_db
- shlink_db_postgres
- shlink_db_maria
- shlink_db_ms
- shlink_redis
- shlink_mercure
- shlink_mercure_proxy
environment:
LC_ALL: C
shlink_db:
container_name: shlink_db
@@ -54,7 +79,7 @@ services:
shlink_db_postgres:
container_name: shlink_db_postgres
image: postgres:10.7-alpine
image: postgres:12.2-alpine
ports:
- "5433:5432"
volumes:
@@ -65,8 +90,51 @@ services:
POSTGRES_DB: shlink
PGDATA: /var/lib/postgresql/data/pgdata
shlink_db_maria:
container_name: shlink_db_maria
image: mariadb:10.5
ports:
- "3308:3306"
volumes:
- ./:/home/shlink/www
- ./data/infra/database_maria:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: shlink
MYSQL_INITDB_SKIP_TZINFO: 1
shlink_db_ms:
container_name: shlink_db_ms
image: mcr.microsoft.com/mssql/server:2019-latest
ports:
- "1433:1433"
environment:
ACCEPT_EULA: Y
SA_PASSWORD: "Passw0rd!"
shlink_redis:
container_name: shlink_redis
image: redis:5.0-alpine
image: redis:6.0-alpine
ports:
- "6380:6379"
shlink_mercure_proxy:
container_name: shlink_mercure_proxy
image: nginx:1.17.10-alpine
ports:
- "8001:80"
volumes:
- ./:/home/shlink/www
- ./data/infra/mercure_proxy_vhost.conf:/etc/nginx/conf.d/default.conf
links:
- shlink_mercure
shlink_mercure:
container_name: shlink_mercure
image: dunglas/mercure:v0.9
ports:
- "3080:80"
environment:
CORS_ALLOWED_ORIGINS: "*"
JWT_KEY: "mercure_jwt_key"
USE_FORWARDED_HEADERS: "1"

View File

@@ -1,6 +1,5 @@
# Shlink Docker image
[![Docker build status](https://img.shields.io/docker/cloud/build/shlinkio/shlink.svg?style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/)
[![Docker pulls](https://img.shields.io/docker/pulls/shlinkio/shlink.svg?style=flat-square)](https://hub.docker.com/r/shlinkio/shlink/)
This image provides an easy way to set up [shlink](https://shlink.io) on a container-based runtime.
@@ -19,7 +18,7 @@ It also expects these two env vars to be provided, in order to properly generate
So based on this, to run shlink on a local docker service, you should run a command like this:
```bash
docker run --name shlink -p 8080:8080 -e SHORT_DOMAIN_HOST=doma.in -e SHORT_DOMAIN_SCHEMA=https shlinkio/shlink
docker run --name shlink -p 8080:8080 -e SHORT_DOMAIN_HOST=doma.in -e SHORT_DOMAIN_SCHEMA=https -e GEOLITE_LICENSE_KEY=kjh23ljkbndskj345 shlinkio/shlink:stable
```
### Interact with shlink's CLI on a running container.
@@ -38,10 +37,10 @@ Or you can list all tags with:
docker exec -it shlink_container shlink tag:list
```
Or process remaining visits with:
Or locate remaining visits with:
```bash
docker exec -it shlink_container shlink visit:process
docker exec -it shlink_container shlink visit:locate
```
All shlink commands will work the same way.
@@ -56,35 +55,91 @@ docker exec -it shlink_container shlink
The image comes with a working sqlite database, but in production you will probably want to usa a distributed database.
It is possible to use a set of env vars to make this shlink instance interact with an external MySQL or PostgreSQL database.
It is possible to use a set of env vars to make this shlink instance interact with an external MySQL, MariaDB, PostgreSQL or Microsoft SQL Server database.
* `DB_DRIVER`: **[Mandatory]**. Use the value **mysql** or **postgres** to prevent the sqlite database to be used.
* `DB_DRIVER`: **[Mandatory]**. Use the value **mysql**, **maria**, **postgres** or **mssql** to prevent the sqlite database to be used.
* `DB_NAME`: [Optional]. The database name to be used. Defaults to **shlink**.
* `DB_USER`: **[Mandatory]**. The username credential for the database server.
* `DB_PASSWORD`: **[Mandatory]**. The password credential for the database server.
* `DB_HOST`: **[Mandatory]**. The host name of the server running the database engine.
* `DB_PORT`: [Optional]. The port in which the database service is running.
* Default value is based on the driver:
* **mysql** -> `3306`
* Default value is based on the value provided for `DB_DRIVER`:
* **mysql** or **maria** -> `3306`
* **postgres** -> `5432`
* **mssql** -> `1433`
> PostgreSQL is supported since v1.16.1 of this image. Do not try to use it with previous versions.
> PostgreSQL is supported since v1.16.1 and Microsoft SQL server since v2.1.0. Do not try to use them with previous versions.
Taking this into account, you could run shlink on a local docker service like this:
```bash
docker run --name shlink -p 8080:8080 -e SHORT_DOMAIN_HOST=doma.in -e SHORT_DOMAIN_SCHEMA=https -e DB_DRIVER=mysql -e DB_USER=root -e DB_PASSWORD=123abc -e DB_HOST=something.rds.amazonaws.com shlinkio/shlink
docker run \
--name shlink \
-p 8080:8080 \
-e SHORT_DOMAIN_HOST=doma.in \
-e SHORT_DOMAIN_SCHEMA=https \
-e DB_DRIVER=mysql \
-e DB_USER=root \
-e DB_PASSWORD=123abc \
-e DB_HOST=something.rds.amazonaws.com \
shlinkio/shlink:stable
```
You could even link to a local database running on a different container:
```bash
docker run --name shlink -p 8080:8080 [...] -e DB_HOST=some_mysql_container --link some_mysql_container shlinkio/shlink
docker run \
--name shlink \
-p 8080:8080 \
[...] \
-e DB_HOST=some_mysql_container \
--link some_mysql_container \
shlinkio/shlink:stable
```
> If you have considered using SQLite but sharing the database file with a volume, read [this issue](https://github.com/shlinkio/shlink-docker-image/issues/40) first.
## Supported env vars
## Other integrations
### Use an external redis server
If you plan to run more than one Shlink instance, there are some resources that should be shared ([Multi instance considerations](#multi-instance-considerations)).
One of those resources are the locks Shlink generates to prevent some operations to be run more than once in parallel (in the future, these redis servers could be used for other caching operations).
In order to share those locks, you should use an external redis server (or a cluster of redis servers), by providing the `REDIS_SERVERS` env var.
It can be either one server name or a comma-separated list of servers.
> If more than one redis server is provided, Shlink will expect them to be configured as a [redis cluster](https://redis.io/topics/cluster-tutorial).
### Integrate with a mercure hub server
One way to get real time updates when certain events happen in Shlink is by integrating it with a [mercure hub](https://mercure.rocks/) server.
If you do that, Shlink will publish updates and other clients can subscribe to those.
There are three env vars you need to provide if you want to enable this:
* `MERCURE_PUBLIC_HUB_URL`: **[Mandatory]**. The public URL of a mercure hub server to which Shlink will sent updates. This URL will also be served to consumers that want to subscribe to those updates.
* `MERCURE_INTERNAL_HUB_URL`: **[Optional]**. An internal URL for a mercure hub. Will be used only when publishing updates to mercure, and does not need to be public. If this is not provided, the `MERCURE_PUBLIC_HUB_URL` one will be used to publish updates.
* `MERCURE_JWT_SECRET`: **[Mandatory]**. The secret key that was provided to the mercure hub server, in order to be able to generate valid JWTs for publishing/subscribing to that server.
So in order to run shlink with mercure integration, you would do it like this:
```bash
docker run \
--name shlink \
-p 8080:8080 \
-e SHORT_DOMAIN_HOST=doma.in \
-e SHORT_DOMAIN_SCHEMA=https \
-e "MERCURE_PUBLIC_HUB_URL=https://example.com"
-e "MERCURE_INTERNAL_HUB_URL=http://my-mercure-hub.prod.svc.cluster.local"
-e MERCURE_JWT_SECRET=super_secret_key
shlinkio/shlink:stable
```
## All supported env vars
A few env vars have been already used in previous examples, but this image supports others that can be used to customize its behavior.
@@ -92,25 +147,33 @@ This is the complete list of supported env vars:
* `SHORT_DOMAIN_HOST`: The custom short domain used for this shlink instance. For example **doma.in**.
* `SHORT_DOMAIN_SCHEMA`: Either **http** or **https**.
* `SHORTCODE_CHARS`: A charset to use when building short codes. Only needed when using more than one shlink instance ([Multi instance considerations](#multi-instance-considerations)).
* `DB_DRIVER`: **sqlite** (which is the default value), **mysql** or **postgres**.
* `DB_DRIVER`: **sqlite** (which is the default value), **mysql**, **maria**, **postgres** or **mssql**.
* `DB_NAME`: The database name to be used when using an external database driver. Defaults to **shlink**.
* `DB_USER`: The username credential to be used when using an external database driver.
* `DB_PASSWORD`: The password credential to be used when using an external database driver.
* `DB_HOST`: The host name of the database server when using an external database driver.
* `DB_PORT`: The port in which the database service is running when using an external database driver. Defaults to **3306**.
* `DB_PORT`: The port in which the database service is running when using an external database driver.
* Default value is based on the value provided for `DB_DRIVER`:
* **mysql** or **maria** -> `3306`
* **postgres** -> `5432`
* **mssql** -> `1433`
* `DISABLE_TRACK_PARAM`: The name of a query param that can be used to visit short URLs avoiding the visit to be tracked. This feature won't be available if not value is provided.
* `DELETE_SHORT_URL_THRESHOLD`: The amount of visits on short URLs which will not allow them to be deleted. Defaults to `15`.
* `VALIDATE_URLS`: Boolean which tells if shlink should validate a status 20x (after following redirects) is returned when trying to shorten a URL. Defaults to `true`.
* `NOT_FOUND_REDIRECT_TO`: If a URL is provided here, when a user tries to access an invalid short URL, he/she will be redirected to this value. If this env var is not provided, the user will see a generic `404 - not found` page.
* `VALIDATE_URLS`: Boolean which tells if shlink should validate a status 20x is returned (after following redirects) when trying to shorten a URL. Defaults to `false`.
* `INVALID_SHORT_URL_REDIRECT_TO`: If a URL is provided here, when a user tries to access an invalid short URL, he/she will be redirected to this value. If this env var is not provided, the user will see a generic `404 - not found` page.
* `REGULAR_404_REDIRECT_TO`: If a URL is provided here, when a user tries to access a URL not matching any one supported by the router, he/she will be redirected to this value. If this env var is not provided, the user will see a generic `404 - not found` page.
* `BASE_URL_REDIRECT_TO`: If a URL is provided here, when a user tries to access Shlink's base URL, he/she will be redirected to this value. If this env var is not provided, the user will see a generic `404 - not found` page.
* `BASE_PATH`: The base path from which you plan to serve shlink, in case you don't want to serve it from the root of the domain. Defaults to `''`.
* `WEB_WORKER_NUM`: The amount of concurrent http requests this shlink instance will be able to server. Defaults to 16.
* `TASK_WORKER_NUM`: The amount of concurrent background tasks this shlink instance will be able to execute. Defaults to 16.
* `VISITS_WEBHOOKS`: A comma-separated list of URLs that will receive a `POST` request when a short URL receives a visit.
* `DEFAULT_SHORT_CODES_LENGTH`: The length you want generated short codes to have. It defaults to 5 and has to be at least 4, so any value smaller than that will fall back to 4.
* `GEOLITE_LICENSE_KEY`: The license key used to download new GeoLite2 database files. This is not mandatory, as a default license key is provided, but it is **strongly recommended** that you provide your own. Go to [https://shlink.io/documentation/geolite-license-key](https://shlink.io/documentation/geolite-license-key) to know how to generate it.
* `REDIS_SERVERS`: A comma-separated list of redis servers where Shlink locks are stored (locks are used to prevent some operations to be run more than once in parallel).
This is important when running more than one Shlink instance ([Multi instance considerations](#multi-instance-considerations)). If not provided, Shlink stores locks on every instance separately.
If more than one server is provided, Shlink will expect them to be configured as a [redis cluster](https://redis.io/topics/cluster-tutorial).
In the future, these redis servers could be used for other caching operations performed by shlink.
* `MERCURE_PUBLIC_HUB_URL`: The public URL of a mercure hub server to which Shlink will sent updates. This URL will also be served to consumers that want to subscribe to those updates.
* `MERCURE_INTERNAL_HUB_URL`: An internal URL for a mercure hub. Will be used only when publishing updates to mercure, and does not need to be public. If this is not provided but `MERCURE_PUBLIC_HUB_URL` was, the former one will be used to publish updates.
* `MERCURE_JWT_SECRET`: The secret key that was provided to the mercure hub server, in order to be able to generate valid JWTs for publishing/subscribing to that server.
* `ANONYMIZE_REMOTE_ADDR`: Tells if IP addresses from visitors should be obfuscated before storing them in the database. Default value is `true`. **Careful!** Setting this to `false` will make your Shlink instance no longer be in compliance with the GDPR and other similar data protection regulations.
An example using all env vars could look like this:
@@ -128,11 +191,22 @@ docker run \
-e DB_PORT=3306 \
-e DISABLE_TRACK_PARAM="no-track" \
-e DELETE_SHORT_URL_THRESHOLD=30 \
-e VALIDATE_URLS=false \
-e "NOT_FOUND_REDIRECT_TO=https://www.google.com" \
-e VALIDATE_URLS=true \
-e "INVALID_SHORT_URL_REDIRECT_TO=https://my-landing-page.com" \
-e "REGULAR_404_REDIRECT_TO=https://my-landing-page.com" \
-e "BASE_URL_REDIRECT_TO=https://my-landing-page.com" \
-e "REDIS_SERVERS=tcp://172.20.0.1:6379,tcp://172.20.0.2:6379" \
-e "BASE_PATH=/my-campaign" \
shlinkio/shlink
-e WEB_WORKER_NUM=64 \
-e TASK_WORKER_NUM=32 \
-e "VISITS_WEBHOOKS=http://my-api.com/api/v2.3/notify,https://third-party.io/foo" \
-e DEFAULT_SHORT_CODES_LENGTH=6 \
-e GEOLITE_LICENSE_KEY=kjh23ljkbndskj345 \
-e "MERCURE_PUBLIC_HUB_URL=https://example.com" \
-e "MERCURE_INTERNAL_HUB_URL=http://my-mercure-hub.prod.svc.cluster.local" \
-e MERCURE_JWT_SECRET=super_secret_key \
-e ANONYMIZE_REMOTE_ADDR=false \
shlinkio/shlink:stable
```
## Provide config via volumes
@@ -149,12 +223,22 @@ The whole configuration should have this format, but it can be split into multip
"delete_short_url_threshold": 30,
"short_domain_schema": "https",
"short_domain_host": "doma.in",
"validate_url": false,
"not_found_redirect_to": "https://my-landing-page.com",
"validate_url": true,
"invalid_short_url_redirect_to": "https://my-landing-page.com",
"regular_404_redirect_to": "https://my-landing-page.com",
"base_url_redirect_to": "https://my-landing-page.com",
"base_path": "/my-campaign",
"web_worker_num": 64,
"task_worker_num": 32,
"default_short_codes_length": 6,
"redis_servers": [
"tcp://172.20.0.1:6379",
"tcp://172.20.0.2:6379"
],
"visits_webhooks": [
"http://my-api.com/api/v2.3/notify",
"https://third-party.io/foo"
],
"db_config": {
"driver": "pdo_mysql",
"dbname": "shlink",
@@ -162,7 +246,12 @@ The whole configuration should have this format, but it can be split into multip
"password": "123abc",
"host": "something.rds.amazonaws.com",
"port": "3306"
}
},
"geolite_license_key": "kjh23ljkbndskj345",
"mercure_public_hub_url": "https://example.com",
"mercure_internal_hub_url": "http://my-mercure-hub.prod.svc.cluster.local",
"mercure_jwt_secret": "super_secret_key",
"anonymize_remote_addr": false
}
```
@@ -171,21 +260,13 @@ The whole configuration should have this format, but it can be split into multip
Once created just run shlink with the volume:
```bash
docker run --name shlink -p 8080:8080 -v ${PWD}/my/config/dir:/etc/shlink/config/params shlinkio/shlink
docker run --name shlink -p 8080:8080 -v ${PWD}/my/config/dir:/etc/shlink/config/params shlinkio/shlink:stable
```
## Multi instance considerations
These are some considerations to take into account when running multiple instances of shlink.
* The first time shlink is run, it generates a charset used to generate short codes, which is a shuffled base62 charset.
If you are using several shlink instances, you will probably want all of them to use the same charset.
You can get a shuffled base62 charset by going to [https://shlink.io/short-code-chars](https://shlink.io/short-code-chars), and then you just need to pass it to all shlink instances using the `SHORTCODE_CHARS` env var.
If you don't do this, each shlink instance will use a different charset. However this shouldn't be a problem in practice, since the chances to get a collision will be very low.
* Some operations performed by Shlink should never be run more than once at the same time (like creating the database for the first time, or downloading the GeoLite2 database). For this reason, Shlink uses a locking system.
However, these locks are locally scoped to each Shlink instance by default.
@@ -194,10 +275,10 @@ These are some considerations to take into account when running multiple instanc
## Versions
Versions of this image match the shlink version it contains.
Versioning on this docker image works as follows:
For example, installing `shlinkio/shlink:1.15.0`, you will get an image containing shlink v1.15.0.
* `X.X.X`: when providing a specific version number, the image version will match the shlink version it contains. For example, installing `shlinkio/shlink:1.15.0`, you will get an image containing shlink v1.15.0.
* `stable`: always holds the latest stable tag. For example, if latest shlink version is 2.0.0, installing `shlinkio/shlink:stable`, you will get an image containing shlink v2.0.0
* `latest`: always holds the latest contents in master, and it's considered unstable and not suitable for production.
The `latest` docker tag always holds the latest contents in master, and it's considered unestable and not suitable for production.
> There are no official shlink images previous to v1.15.0.
> **Important**: The docker image was introduced with shlink v1.15.0, so there are no official images previous to that versions.

17
docker/build Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
set -e
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
# If there is a tag, regardless the branch, build that docker tag and also "stable"
if [[ ! -z $TRAVIS_TAG ]]; then
docker build --build-arg SHLINK_VERSION=${TRAVIS_TAG#?} -t shlinkio/shlink:${TRAVIS_TAG#?} -t shlinkio/shlink:stable .
docker push shlinkio/shlink:${TRAVIS_TAG#?}
# Push stable tag only if this is not an alpha or beta tag
[[ $TRAVIS_TAG != *"alpha"* && $TRAVIS_TAG != *"beta"* ]] && docker push shlinkio/shlink:stable
# If build branch is develop, build latest (on master, when there's no tag, do not build anything)
elif [[ "$TRAVIS_BRANCH" == 'develop' ]]; then
docker build -t shlinkio/shlink:latest .
docker push shlinkio/shlink:latest
fi

3
docker/config/php.ini Normal file
View File

@@ -0,0 +1,3 @@
log_errors_max_len=0
zend.assertions=1
assert.exception=1

View File

@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace Shlinkio\Shlink;
@@ -7,73 +8,26 @@ use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use function explode;
use function file_exists;
use function file_get_contents;
use function file_put_contents;
use function implode;
use function Functional\contains;
use function Shlinkio\Shlink\Common\env;
use function sprintf;
use function str_shuffle;
use function substr;
use function sys_get_temp_dir;
use const Shlinkio\Shlink\Core\DEFAULT_SHORT_CODES_LENGTH;
use const Shlinkio\Shlink\Core\MIN_SHORT_CODES_LENGTH;
$helper = new class {
private const BASE62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
private const DB_DRIVERS_MAP = [
'mysql' => 'pdo_mysql',
'maria' => 'pdo_mysql',
'postgres' => 'pdo_pgsql',
'mssql' => 'pdo_sqlsrv',
];
private const DB_PORTS_MAP = [
'mysql' => '3306',
'maria' => '3306',
'postgres' => '5432',
'mssql' => '1433',
];
/** @var string */
private $charset;
/** @var string */
private $secretKey;
public function __construct()
{
[$this->charset, $this->secretKey] = $this->initShlinkKeys();
}
private function initShlinkKeys(): array
{
$keysFile = sprintf('%s/shlink.keys', sys_get_temp_dir());
if (file_exists($keysFile)) {
return explode(',', file_get_contents($keysFile));
}
$keys = [
env('SHORTCODE_CHARS', $this->generateShortcodeChars()),
env('SECRET_KEY', $this->generateSecretKey()),
];
file_put_contents($keysFile, implode(',', $keys));
return $keys;
}
private function generateShortcodeChars(): string
{
return str_shuffle(self::BASE62);
}
private function generateSecretKey(): string
{
return substr(str_shuffle(self::BASE62), 0, 32);
}
public function getShortcodeChars(): string
{
return $this->charset;
}
public function getSecretKey(): string
{
return $this->secretKey;
}
public function getDbConfig(): array
{
$driver = env('DB_DRIVER');
@@ -84,9 +38,11 @@ $helper = new class {
];
}
$driverOptions = $driver !== 'mysql' ? [] : [
// PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
$driverOptions = ! contains(['maria', 'mysql'], $driver) ? [] : [
// 1002 -> PDO::MYSQL_ATTR_INIT_COMMAND
1002 => 'SET NAMES utf8',
// 1000 -> PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
1000 => true,
];
return [
'driver' => self::DB_DRIVERS_MAP[$driver],
@@ -99,13 +55,41 @@ $helper = new class {
];
}
public function getNotFoundConfig(): array
public function getNotFoundRedirectsConfig(): array
{
$notFoundRedirectTo = env('NOT_FOUND_REDIRECT_TO');
return [
'invalid_short_url' => env('INVALID_SHORT_URL_REDIRECT_TO'),
'regular_404' => env('REGULAR_404_REDIRECT_TO'),
'base_url' => env('BASE_URL_REDIRECT_TO'),
];
}
public function getVisitsWebhooks(): array
{
$webhooks = env('VISITS_WEBHOOKS');
return $webhooks === null ? [] : explode(',', $webhooks);
}
public function getRedisConfig(): ?array
{
$redisServers = env('REDIS_SERVERS');
return $redisServers === null ? null : ['servers' => $redisServers];
}
public function getDefaultShortCodesLength(): int
{
$value = (int) env('DEFAULT_SHORT_CODES_LENGTH', DEFAULT_SHORT_CODES_LENGTH);
return $value < MIN_SHORT_CODES_LENGTH ? MIN_SHORT_CODES_LENGTH : $value;
}
public function getMercureConfig(): array
{
$publicUrl = env('MERCURE_PUBLIC_HUB_URL');
return [
'enable_redirection' => $notFoundRedirectTo !== null,
'redirect_to' => $notFoundRedirectTo,
'public_hub_url' => $publicUrl,
'internal_hub_url' => env('MERCURE_INTERNAL_HUB_URL', $publicUrl),
'jwt_secret' => env('MERCURE_JWT_SECRET'),
];
}
};
@@ -115,7 +99,6 @@ return [
'config_cache_enabled' => false,
'app_options' => [
'secret_key' => $helper->getSecretKey(),
'disable_track_param' => env('DISABLE_TRACK_PARAM'),
],
@@ -133,27 +116,24 @@ return [
'schema' => env('SHORT_DOMAIN_SCHEMA', 'http'),
'hostname' => env('SHORT_DOMAIN_HOST', ''),
],
'shortcode_chars' => $helper->getShortcodeChars(),
'validate_url' => (bool) env('VALIDATE_URLS', true),
'not_found_short_url' => $helper->getNotFoundConfig(),
'validate_url' => (bool) env('VALIDATE_URLS', false),
'anonymize_remote_addr' => (bool) env('ANONYMIZE_REMOTE_ADDR', true),
'visits_webhooks' => $helper->getVisitsWebhooks(),
'default_short_codes_length' => $helper->getDefaultShortCodesLength(),
],
'logger' => [
'handlers' => [
'shlink_rotating_handler' => [
'level' => Logger::EMERGENCY, // This basically disables regular file logs
],
'shlink_stdout_handler' => [
'class' => StreamHandler::class,
'level' => Logger::INFO,
'stream' => 'php://stdout',
'formatter' => 'dashed',
],
],
'not_found_redirects' => $helper->getNotFoundRedirectsConfig(),
'loggers' => [
'Shlink' => [
'handlers' => ['shlink_stdout_handler'],
'logger' => [
'Shlink' => [
'handlers' => [
'shlink_handler' => [
'name' => StreamHandler::class,
'params' => [
'level' => Logger::INFO,
'stream' => 'php://stdout',
],
],
],
],
],
@@ -164,12 +144,27 @@ return [
],
],
'redis' => [
'servers' => env('REDIS_SERVERS'),
'cache' => [
'redis' => $helper->getRedisConfig(),
],
'router' => [
'base_path' => env('BASE_PATH', ''),
],
'mezzio-swoole' => [
'swoole-http-server' => [
'options' => [
'worker_num' => (int) env('WEB_WORKER_NUM', 16),
'task_worker_num' => (int) env('TASK_WORKER_NUM', 16),
],
],
],
'geolite2' => [
'license_key' => env('GEOLITE_LICENSE_KEY', 'G4Lm0C60yJsnkdPi'),
],
'mercure' => $helper->getMercureConfig(),
];

View File

@@ -12,6 +12,9 @@ php bin/cli db:migrate -n -q
echo "Generating proxies..."
php vendor/doctrine/orm/bin/doctrine.php orm:generate-proxies -n -q
echo "Clearing entities cache..."
php vendor/doctrine/orm/bin/doctrine.php orm:clear-cache:metadata -n -q
# When restarting the container, swoole might think it is already in execution
# This forces the app to be started every second until the exit code is 0
until php vendor/zendframework/zend-expressive-swoole/bin/zend-expressive-swoole start; do sleep 1 ; done
until php vendor/mezzio/mezzio-swoole/bin/mezzio-swoole start; do sleep 1 ; done

View File

@@ -0,0 +1,210 @@
{
"asyncapi": "2.0.0",
"info": {
"title": "Shlink",
"version": "2.0.0",
"description": "Shlink, the self-hosted URL shortener",
"license": {
"name": "MIT",
"url": "https://github.com/shlinkio/shlink/blob/develop/LICENSE"
}
},
"defaultContentType": "application/json",
"channels": {
"http://shlink.io/new-visit": {
"subscribe": {
"summary": "Receive information about any new visit occurring on any short URL.",
"operationId": "newVisit",
"message": {
"payload": {
"type": "object",
"additionalProperties": false,
"properties": {
"shortUrl": {
"$ref": "#/components/schemas/ShortUrl"
},
"visit": {
"$ref": "#/components/schemas/Visit"
}
}
}
}
}
},
"http://shlink.io/new-visit/{shortCode}": {
"parameters": {
"shortCode": {
"description": "The short code of the short URL",
"schema": {
"type": "string"
}
}
},
"subscribe": {
"summary": "Receive information about any new visit occurring on a specific short URL.",
"operationId": "newShortUrlVisit",
"message": {
"payload": {
"type": "object",
"additionalProperties": false,
"properties": {
"shortUrl": {
"$ref": "#/components/schemas/ShortUrl"
},
"visit": {
"$ref": "#/components/schemas/Visit"
}
}
}
}
}
}
},
"components": {
"schemas": {
"ShortUrl": {
"type": "object",
"properties": {
"shortCode": {
"type": "string",
"description": "The short code for this short URL."
},
"shortUrl": {
"type": "string",
"description": "The short URL."
},
"longUrl": {
"type": "string",
"description": "The original long URL."
},
"dateCreated": {
"type": "string",
"format": "date-time",
"description": "The date in which the short URL was created in ISO format."
},
"visitsCount": {
"type": "integer",
"description": "The number of visits that this short URL has recieved."
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "A list of tags applied to this short URL"
},
"meta": {
"$ref": "#/components/schemas/ShortUrlMeta"
},
"domain": {
"type": "string",
"description": "The domain in which the short URL was created. Null if it belongs to default domain."
}
},
"example": {
"shortCode": "12C18",
"shortUrl": "https://doma.in/12C18",
"longUrl": "https://store.steampowered.com",
"dateCreated": "2016-08-21T20:34:16+02:00",
"visitsCount": 328,
"tags": [
"games",
"tech"
],
"meta": {
"validSince": "2017-01-21T00:00:00+02:00",
"validUntil": null,
"maxVisits": 100
},
"domain": "example.com"
}
},
"ShortUrlMeta": {
"type": "object",
"required": [
"validSince",
"validUntil",
"maxVisits"
],
"properties": {
"validSince": {
"description": "The date (in ISO-8601 format) from which this short code will be valid",
"type": "string",
"nullable": true
},
"validUntil": {
"description": "The date (in ISO-8601 format) until which this short code will be valid",
"type": "string",
"nullable": true
},
"maxVisits": {
"description": "The maximum number of allowed visits for this short code",
"type": "number",
"nullable": true
}
}
},
"Visit": {
"type": "object",
"properties": {
"referer": {
"type": "string",
"description": "The origin from which the visit was performed"
},
"date": {
"type": "string",
"format": "date-time",
"description": "The date in which the visit was performed"
},
"userAgent": {
"type": "string",
"description": "The user agent from which the visit was performed"
},
"visitLocation": {
"$ref": "#/components/schemas/VisitLocation"
}
},
"example": {
"referer": "https://t.co",
"date": "2015-08-20T05:05:03+04:00",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36",
"visitLocation": {
"cityName": "Cupertino",
"countryCode": "US",
"countryName": "United States",
"latitude": 37.3042,
"longitude": -122.0946,
"regionName": "California",
"timezone": "America/Los_Angeles"
}
}
},
"VisitLocation": {
"type": "object",
"properties": {
"cityName": {
"type": "string"
},
"countryCode": {
"type": "string"
},
"countryName": {
"type": "string"
},
"latitude": {
"type": "number"
},
"longitude": {
"type": "number"
},
"regionName": {
"type": "string"
},
"timezone": {
"type": "string"
}
}
}
}
}
}

View File

@@ -1,13 +1,22 @@
{
"type": "object",
"required": ["type", "title", "detail", "status"],
"properties": {
"code": {
"type": {
"type": "string",
"description": "A machine unique code"
},
"message": {
"title": {
"type": "string",
"description": "A human-friendly error message"
"description": "A unique title"
},
"detail": {
"type": "string",
"description": "A human-friendly error description"
},
"status": {
"type": "number",
"description": "HTTP response status code"
}
}
}

View File

@@ -0,0 +1,18 @@
{
"type": "object",
"required": ["mercureHubUrl", "jwt", "jwtExpiration"],
"properties": {
"mercureHubUrl": {
"type": "string",
"description": "The public URL of the mercure hub that can be used to get real-time updates published by Shlink"
},
"jwt": {
"type": "string",
"description": "A JWT with subscribe permissions which is valid with the mercure hub"
},
"jwtExpiration": {
"type": "string",
"description": "The date (in ISO-8601 format) in which the JWT will expire"
}
}
}

Some files were not shown because too many files have changed in this diff Show More