이것은 크라우드 소싱 프로젝트 및 설문지를위한 Laravel 웹 응용 프로그램입니다.
.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 bashMySQL 쉘을 입력하십시오.
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:seedPHP 컨테이너를 입력하십시오 (Docker Compose를 사용하는 경우) :
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 캐시에 유지합니다.
php artisan config:cache이 폴더를 공개 디렉토리와 연결하려면
이 앱은 Socialite 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 구성 파일에서 생성 된 두 파일을 참조하십시오. 아래와 같이 포트를 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 Siteemap 플러그인을 사용하여 검색 엔진에 의해 크롤링되는 public/sitemap.xml 파일 (GIT에서 제외)을 만듭니다. 현재 애플리케이션 설치의 발전기를 실행하려면 내장 된 Laravel 명령을 실행하십시오.
php artisan sitemap:generate이 응용 프로그램은 코드 스타일을 수행하기 위해 Laravel Pint를 사용합니다.
스타일러를 실행하려면 실행하십시오.
./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 및 Pretier를 사용합니다.
스타일러와 포메 라터를 실행하려면 달리기를 실행하십시오.
npm run lint # this command will check the code style
npm run format # this command will format the code style 이 프로젝트는 무료 adminlte 템플릿을 사용합니다.
또한 부트 스트랩 4를 사용합니다
응용 프로그램은 각 설치에 대해 조정 및 개인화 할 수 있습니다. .env 파일에서 INSTALLATION_RESOURCES_DIR 변수를 그에 따라 설정할 수 있습니다. 이 변수는 resourcess/views/home/partials 디렉토리의 디렉토리 이름을 나타내는 값을 가져야합니다. 예를 들어, resourcess/views/home/partials/together Directory를 참조하십시오. 이 디렉토리에는 설치를위한 부분 블레이드 파일이 포함되어야합니다.
이 문서 의이 부분은 Laravel 애플리케이션의 디렉토리 구조를 설명합니다.
대부분 응용 프로그램에 사용되는 사용자 정의 디렉토리 및 파일로 범위가납니다. General 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 메소드에서 아동 저장소 클래스에서 참조됩니다.
따라서 각 어린이 클래스에서 동일한 쿼리를 작성하지 않고도 getAll , getById , create , update 와 같은 Repository 클래스에 정의 된 기본 메소드를 사용할 수 있습니다. 아동 클래스에서 사용자 정의 쿼리를 정의하거나 필요한 경우 기본 방법을 재정의 할 수도 있습니다.
리포지토리 클래스는 비즈니스 로직을 포함하고 컨트롤러에서 데이터 액세스 계층으로의 대의원을 포함하는 비즈니스 로직 계층 클래스에서 사용됩니다.
저장소 패턴에 대한 자세한 내용은 여기를 참조하십시오.
캐시 및 구성 파일을 지 웠는지 확인하십시오.
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 명령과 함께 PHPUNIT Laravel 명령 인 php artisan test 명령을 사용하여 테스트를 실행할 수 있습니다.
마지막으로 테스트를 실행하십시오.
# 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 스크립트로 테스트를 실행하십시오 phpunit 명령 주변의 래퍼 인 run-tests.sh 스크립트를 사용하여 테스트를 실행할 수도 있습니다.
chmod +x run-tests.sh
./run-tests.sh 이것은 또한 phpunit 명령으로 전달할 인수 ( --filter 또는 --coverage 플래그)를 취할 수 있습니다.
./run-tests.sh --filter {METHOD OR CLASS NAME}또는
./run-tests.sh --coverageDocker 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에서 나온 것입니다.
프로젝트 관리자에게 문의하십시오.