- Technologies used in the project
- Project setup
- Importing database
- Configuration
- Setting up Apache
- Server endpoints
- Postman commands
- Notes
PHP
PHPStan
Steps to set up the project:
- Import database
- Create configuration files
- Set up Apache
To import the database, run this command
mysql -u username -p [Database name] < "./project_files/database_dump.sql"
Create config files with data for SMTP and MySQL in the ./src/Config/Secret/
folder.
Examples of configuration are inside ./src/Config/SecretExample/
.
You can set up Apache, or you can run the bash script ./devServer.sh
to run the
development server.
The configuration file for your virtual server should look like this
(default folder is /var/www/html
):
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName cloud-storage.local
ServerAlias www.cloud-storage.local
ErrorLog "/var/log/apache2/cloud-storage.local-error.log"
CustomLog "/var/log/apache2/cloud-storage.local-access.log"
common
<Directory /var/www/html/>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
Make sure that apache_mod_rewrite
is enabled.
dob
, gender
can be null
. lastName
can be empty string.
gender
can be either "M" or "F".
If parentId
is received as null
it is considered a root directory.
GET: /users/list
- Get a list of users with safe information
GET: /users/get/{userId}
- Get the safe information about a specific user
GET: /users/search/{email}
- Search users by email
Return data:
{
"id": 18,
"firstName": "John",
"lastName": "Smith",
"email": "[email protected]",
"dob": {
"date": "1997-06-25 00:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"gender": "M"
}
PUT: /users/update
- Change current user info
Receives:
{
"firstName": "John",
"lastName": "Smith",
"dob": "1997-06-25",
"gender": "M"
}
POST: /users/login
- Log into account
Receives:
{
"email": "[email protected]",
"password": "password"
}
GET: /users/[email protected]
- Send reset token
to the user's mail
Receives: Query parameter email
POST: /users/reset_password
- Reset password
Receives:
{
"email": "[email protected]",
"password": "password",
"token": "P+axG5k9gStneqbLmH9K4e3u8DIv0Bdh6iPUDu4zFbxuyd7GjuUBWXPc/x8eTgb+Mh75WuTF41jlu5Qh"
}
POST: /users/register
- Register
Receives:
{
"firstName": "John",
"lastName": "Smith",
"email":"[email protected]",
"password": "password",
"dob": "1994-06-25",
"gender": "M"
}
POST: /users/verify_email
- Confirm email
Receives:
{
"email": "[email protected]",
"token": "inuRtdsDIaACMkvca4z32ONxKL9QZ74jBiGaFwwgb0fMvcNdiK8+iWUUn1cMIbbPAOrprZyN8IfUU8Yx"
}
GET: /admin/list
- Get users list with full information
GET: /admin/get/{userId}
- Get full info about a specific user
Return data:
{
"id": 13,
"firstName": "John",
"lastName": "Smith",
"email": "[email protected]",
"isAdmin": true,
"dob": {
"date": "1997-06-25 00:00:00.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"gender": "M",
"isEmailVerified": true
}
PUT: /admin/update/{userId}
- Change user data
Receives:
{
"firstName": "John",
"lastName": "Smith",
"email": "[email protected]",
"isAdmin": true,
"dob": "1997-06-25",
"gender": "M"
}
DELETE: /admin/delete/{userId}
- Delete user
POST: /directories/add
- Add a folder
Receives:
{
"name": "Directory name",
"parentId": null
}
PUT: /directories/rename/{directoryId}
- Rename a folder
Receives:
{
"name": "New name"
}
GET: /directories/get
- Get info about the root folder
GET: /directories/get/{directoryId}
- Get info about a specific folder
Return data:
{
"properties": {
"id": 41,
"name": "Directory name",
"userId": 13,
"parentId": null
},
"folders": [
{
"id": 46,
"name": "Directory name",
"userId": 13,
"parentId": 41
}
],
"files": [
{
"id": 71,
"name": "night_city.jpg",
"userId": 13,
"folderId": 41,
"createdAt": {
"date": "2023-11-29 18:02:42.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updatedAt": {
"date": "2023-11-29 18:02:42.000000",
"timezone_type": 3,
"timezone": "UTC"
}
}
]
}
DELETE: /directories/delete/{directoryId}
- Delete folder
GET: /files/list
- Get a list of files
GET: /files/list-shared
- Get a list of files from other users who shared
the file with current user
GET: /files/get/{fileId}
- Get information about a file
Return data:
{
"id": 71,
"name": "night_city.jpg",
"userId": 13,
"folderId": 41,
"createdAt": {
"date": "2023-11-29 18:02:42.000000",
"timezone_type": 3,
"timezone": "UTC"
},
"updatedAt": {
"date": "2023-11-29 18:02:42.000000",
"timezone_type": 3,
"timezone": "UTC"
}
}
GET: /files/download/{fileId}
- Download file
Returns a file.
POST: /files/add
- Add a file
Receives:
Two POST parameters folderId
and file
PUT: /files/rename/{fileId}
- Rename a file
Receives:
{
"name": "New name"
}
DELETE: /files/remove/{fileId}
- Delete file
GET: /files/share/{fileId}
- Get users list who have access to file
Receives:
[
{
"id": 15,
"userId": 17,
"fileId": 71
}
]
PUT: /files/share/{fileId}/{userId}
- Share file
DELETE: /files/share/{fileId}/{userId}
- Revoke access to a file for user
File with Postman commands for testing is inside the ./project_files/
folder.
It's possible to change how internal server errors are handled by modifying
the config file inside ./src/Config/config.env
.
With DEV=true
the exception messages are being sent in response body.
With DEBUG=true
exceptions are thrown and their messages are displayed in
a response body
Also, in config file, you can change maximum file size and default
total available space for users.