这是用于众包项目和问卷的Laravel Web应用程序。
.env文件.env设置在开源许可下提供代码包括许多好处。其中,与我们的项目相关的是:
ECAS官方安装
官方安装
为了清楚起见,设置说明已分为两个部分:
无论安装方法如何,您都需要运行以下命令来设置应用程序。
这些命令应在任何Docker容器之外运行:
sudo chown -R ` whoami ` :www-data storage
chmod 775 storage
cd storage/
find . -type f -exec chmod 664 {} ;
find . -type d -exec chmod 775 {} ;根据安装方法,您应该在Docker容器或本地计算机上运行其余步骤。
注意:如果您使用的是Docker Compose,则首先需要首先输入PHP容器:
docker exec -it crowdsourcing_platform_server bash然后运行其余的命令。
如果要在本地计算机上运行命令,则可以直接运行以下命令。
如果您已经启动了DDEV,则应运行所有带有ddev exec命令。
.env文件克隆项目后,创建.ENV文件(应该是.env.example的副本):
cp .env.example .env如果进行非骗子安装,则需要为应用程序创建数据库。
如果有Docker环境,请输入crowdsourcing_platform_db容器,并创建一个名为crowdsourcing_db_docker的数据库:
docker exec -it crowdsourcing_platform_db bash输入MySQL外壳:
mysql -u root -p然后,运行以下MySQL命令:
CREATE DATABASE IF NOT EXISTS crowdsourcing_db_docker;首先,您需要输入DB容器:
docker exec -it crowdsourcing_platform_db bash如果您有现有的MySQL转储文件,请确保该文件在当前目录中,并将其导入数据库:
mysql -u root -p crowdsourcing_db_docker < dump.sql然后,将以下内容添加到.env文件:
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=crowdsourcing_db_docker
DB_USERNAME=root
DB_PASSWORD=root注意:如果您使用的是Docker Compose,则需要先进入服务器容器:
docker exec -it crowdsourcing_platform_server bashphp artisan migratephp artisan db:seed输入PHP容器(如果使用Docker组成):
docker exec -it crowdsourcing_platform_server bash然后,运行以下命令:
composer install
composer dump-autoloadphp artisan key:generatenpm install
npm run dev # (if in development mode, use for live changes)
npm run build # (if in development mode)
npm run prod # (if in production mode)默认情况下,图像存储在App/Storage/Public中。跑步
php artisan storage:link.env设置然后将.env设置持续到Laravel Cache:
php artisan config:cache为了将此文件夹与公共目录链接
该应用程序使用社交网站Laravel插件来处理社交登录。
为了使其在开发环境中工作,您需要确保您拥有Facebook和Twitter的API密钥和秘密(在此处和此处的指南),并且可以访问机器上的https://dev.crowdsourcing/(请注意https)。
可以在此处找到有关在本地计算机上启用HTTP的指南。
基本上,您需要运行
openssl req -new -sha256 -newkey rsa:2048 -nodes
-keyout dev.crowdsourcing.key -x509 -days 365
-out dev.crowdsourcing.crt在应用程序的NGINX配置文件中引用2个生成的文件。确保将端口更改为443,如下所示:
server {
listen 443 ssl;
server_name dev.crowdsourcing;
ssl_certificate /path/to/dev.crowdsourcing.crt;
ssl_certificate_key /path/to/dev.crowdsourcing.key;
root /var/www/crowdsourcing/public;
add_header X-Frame-Options "SAMEORIGIN" ;
add_header X-XSS-Protection "1; mode=block" ;
add_header X-Content-Type-Options "nosniff" ;
index index.php index.html index.htm index.nginx-debian.html;
charset utf-8;
location / {
try_files $uri $uri / /index.php? $query_string ;
}
location = /favicon.ico { access_log off ; log_not_found off ; }
location = /robots.txt { access_log off ; log_not_found off ; }
error_page 404 /index.php;
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
location ~ /.ht {
deny all ;
}
}另外,请确保通过运行重新启动nginx
sudo systemctl restart nginx该应用程序使用Spatie -Laravel Sitemap插件,以创建public/sitemap.xml文件(从git中排除),该文件将被搜索引擎爬行。为了运行当前应用程序安装的发电机,运行嵌入式Laravel命令:
php artisan sitemap:generate该应用程序使用Laravel品脱来执行代码风格。
为了运行造型器,请运行:
./vendor/bin/pint --test -v # the --test will not do any changes, it will just output the changes needed
./vendor/bin/pint -v # this command will actually perform the code style changes 该应用程序使用Eslint和Prettier来执行代码风格。
为了运行造型器和格式化,请运行:
npm run lint # this command will check the code style
npm run format # this command will format the code style 该项目使用免费的管理模板。
它还利用Bootstrap 4
可以为每个安装对应用程序进行调整和个性化。在.env文件中,您可以相应地设置INSTALLATION_RESOURCES_DIR变量。该变量必须采用一个代表resourcess/views/home/partials目录中的目录名称的值。例如,请参阅resourcess/views/home/partials/together Directory。该目录必须包含用于安装的部分刀片文件。
文档的这一部分描述了Laravel应用程序的目录结构。
它主要范围为应用程序中使用的自定义目录和文件。有关一般的Laravel目录结构,请参阅官方文件。
├── app # Laravel application directory
│ ├── BusinessLogicLayer # Business Logic Layer classes (services that contain the business logic and delegate from Controllers towards the Data Access Layer)
│ ├── Http/Controllers # Controllers directory (classes that handle the HTTP requests, perform the necessary validations/operations and return the responses)
│ ├── Http/Middleware # Middleware directory (classes that handle the HTTP requests before they reach the Controllers)
│ ├── Models # Models directory (ORM classes that represent the database tables and contain the relationships between them)
│ ├── Notifications # Notifications directory (classes that handle the notifications, like emails)
│ ├── ViewModels # View Models directory (classes that contain the data that will be passed to the views)
│ ├── Repository # Repository directory (classes that handle the database operations and contain the DB/ORM queries)
│ resources # Resources directory (contains the views, assets, front-end files, and other resources)
│ ├── views # Views directory (contains the blade files that are used to render the HTML)
│ ├── assets # Assets directory (contains the front-end assets like CSS, JS, images, etc.)
│ ├── js # JavaScript files (contains the Vue.js components and other JS files)
│ ├── sass # SASS files (contains the SASS files that are compiled to CSS)
│ ├── lang # Language files (contains the language files for the translations)
该应用程序使用存储库模式将业务逻辑与数据访问逻辑分开。
所有数据库操作均由包含DB/ORM查询的存储库类处理。
这些类位于app/Repository目录中,它们都扩展了app/Repository/Repository库类。
每个子类代表一个数据库表/实体,并包含该表的查询。该实体是在app/Models目录中定义的,并在getModelClassName方法中由子存储库类引用。
因此,我们可以使用在Repository类中定义的基本方法,例如getAll , getById , create , update ,而无需在每个子类中编写相同的查询。我们还可以在子类中定义自定义查询,或者在需要时覆盖基本方法。
存储库类由业务逻辑层类别使用,其中包含业务逻辑,并从控制器到数据访问层的委托。
有关存储库模式的更多信息,请参见此处。
确保您清除了任何缓存和配置文件:
php artisan cache:clear
php artisan config:clear创建测试数据库文件:
touch storage/database_testing.sqlite给出测试数据库文件的必要权限:
chmod 777 storage/database_testing.sqlite然后,确保您已经设置了测试数据库:
运行测试数据库的迁移和播种机:
php artisan migrate:fresh --seed --env=testing --database=sqlite_testingphp artisan test命令您可以使用php artisan test命令(这是一个内置的Laravel命令)运行测试。
最后,运行测试:
# Note that you filter the tests by using the --filter flag (without the = sign)
php artisan test --env=testing --filter {METHOD OR CLASS NAME} --coveragerun-tests.sh脚本运行测试您还可以使用run-tests.sh脚本运行测试,这是围绕phpunit命令的包装器。
chmod +x run-tests.sh
./run-tests.sh这也可以采用您将传递给Phpunit命令的任何参数(例如--filter或--coverage标志)。
./run-tests.sh --filter {METHOD OR CLASS NAME}或者
./run-tests.sh --coverage通过使用Docker Compose,您可以按照以下步骤进行调试:
docker compose up以启动容器。.vscode/launch.json文件具有以下内容: {
"version" : " 0.2.0 " ,
"configurations" : [
{
"name" : " Listen for Xdebug " ,
"type" : " php " ,
"request" : " launch " ,
"port" : 9003 ,
"pathMappings" : {
"/var/www" : " ${workspaceFolder} "
},
"log" : true
}
]
}现在,您可以开始调试应用程序。
用于调试测试:
docker exec -it crowdsourcing_platform_server bash进入PHP容器。php artisan app:test --filter {METHOD OR CLASS NAME} 。例如, php artisan app:test --filter authenticatedNonAdminUserCannotAccessCreatePage 。 如果遇到任何问题,请参阅以下步骤:
docker compose logssystemctl status nginx和systemctl status php-fpmstorage/logs/laravel.log中的Laravel日志.env文件具有正确的数据库凭据systemctl status mysqlnginx -t 为了为应用程序做出贡献,请按照以下步骤:
git checkout -b <branch_name> 。git commit -m '<commit_message>'git push origin <project_name>/<location>该项目是根据Apache许可证(版本2.0)许可的开源软件。
该项目由Scify和ECAS开发,并基于Laravel框架。该项目由Scify维护。
应用程序中使用的一些图像来自Freepik。
随时与项目维护人员联系: