$> composer create-project --prefer-dist laravel/laravel sudoku
Please follow instruction here : https://mattstauffer.co/blog/removing-all-vue-dependencies-from-laravel
Then, add token and environment utilities for jQuery, look at the following file :
resources/assets/js/bootstrap.js
& add to your metadatas, in layout, the following metadata
<meta name="environment" content="{{ config('app.env') }}">
<meta name="csrf-token" content="{{ csrf_token() }}">
if (mix.config.inProduction) {
mix.version();
}
Then, recreate assets stuff
$> npm run prod
Personal notes : After updating nodejs, you could have to rebuild node-sass
$> npm rebuild node-sass --force
1/ edit stuff in environment file ".env" (note that .env.example is setting up for docker)
2/ migrate database
$> php artisan migrate
Personal notes : If you are using MySQL < 5.7 or MariaDB < 10.2, add to your migrations files
// Prevent errors on MySQL < 5.7 or MariaDB < 10.2
Schema::defaultStringLength(191);
see also : laravel/framework#17508
3/ make auth stuff
$> php artisan make:auth
See also : https://laravel.com/docs/5.4/authentication
"autoload": {
...
"psr-4": {
"sudoku\\": "app/"
}
...
},
- Move app/Providers to app/App/Providers
- Move app/User to app/Domain/Users/Users
- Create app/Infrastructure
- app/App namespace sudoku\App -> the application utilities (like : events, events listeners, providers, notifications, everything that laravel does alone)
- app/Console namespace sudoku\Console -> Every output generated by console commands
- app/Exceptions namespace sudoku\Exceptions -> Every output generated by exceptions
- app/Http namespace sudoku\Http -> Every output generated by HTTP requests
- app/Domain namespace sudoku\Domain -> The application domain, the working part relative to the customer domain
- app/Infrastructure name sudoku\Infrastructure -> Linking Interfaces and Contracts (abstractions classes) that allow vendor pacakages, laravel and Domain to work together (Force rules via Interfaces or specific behaviours via abstractions classes)
See also : https://en.wikipedia.org/wiki/Domain-driven_design See also : http://fideloper.com/hexagonal-architecture See also : https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
In this application, we use two sudoku resolvers libraries.
- the home made one, is used in artisan command
- the composer package xeeeveee/sudoku
- is used to compare execution time with the home made library in artisan command
- is also used to generate grid and solve it in HTTP side of this project
Look at the Sudokus\Resolvers domain (sudoku\Domain\Sudokus\Resolvers).
This is a backtracking resolver that map the puzzle in a stack of nodes to bring closer to a graph
$> composer require xeeeveee/sudoku
This package use backtrack algorithm to resolve a sudoku, it is also able to generate a sudoku grid
See also : https://github.com/xeeeveee/sudoku
$> cp .env.example .env
The docker containers are set to be use from this 127.0.0.1:SPECIFIC_PORT on localhost
- website : http://127.0.0.1:8004
- mysql : http://127.0.0.1:3604
- mailhog : http://127.0.0.1:8029
$> docker-compose --project-name sudoku up -d apache2 php-fpm mysql mailhog
$> docker-compose --project-name sudoku stop
$> docker-compose --project-name sudoku exec workspace php /var/www/artisan migrate
$> composer docker
$> composer docker-stop
$> composer docker-artisan-migrate
$> docker-compose --project-name sudoku exec workspace /var/www/vendor/bin/phpunit
$> docker-compose --project-name sudoku exec workspace /var/www/vendor/bin/phpcs --standard=/var/www/vendor/pragmarx/laravelcs/Standards/Laravel/ app
$> docker-compose --project-name sudoku exec workspace /var/www/vendor/bin/phpcpd app
$> composer docker-test
$> composer docker-test-phpcs
$> composer docker-test-phpcs-duplicated
$> php artisan help sudoku:resolve
$> php artisan sudoku:resolve <path to file with sudoku as raw format>
$> php artisan sudoku:resolve storage/tests/sudoku_easy.json
$> php artisan sudoku:resolve storage/tests/sudoku_medium.json
$> php artisan sudoku:resolve storage/tests/sudoku_hard.json
$> php artisan sudoku:resolve storage/tests/sudoku_impose_1.json
$> php artisan sudoku:resolve storage/tests/sudoku_impose_2.json
$> php artisan sudoku:resolve storage/tests/sudoku_impose_1.json
.
Empty puzzle
0 | 7 | 6 | 0 | 1 | 0 | 0 | 4 | 3
---------------------------------
0 | 0 | 0 | 7 | 0 | 2 | 9 | 0 | 0
---------------------------------
0 | 9 | 0 | 0 | 0 | 6 | 0 | 0 | 0
---------------------------------
0 | 0 | 0 | 0 | 6 | 3 | 2 | 0 | 4
---------------------------------
4 | 6 | 0 | 0 | 0 | 0 | 0 | 1 | 9
---------------------------------
1 | 0 | 5 | 4 | 2 | 0 | 0 | 0 | 0
---------------------------------
0 | 0 | 0 | 2 | 0 | 0 | 0 | 9 | 0
---------------------------------
0 | 0 | 4 | 8 | 0 | 7 | 0 | 0 | 1
---------------------------------
9 | 1 | 0 | 0 | 5 | 0 | 7 | 2 | 0
.
First solution with Xeeeveee\Sudoku\Puzzle package
2 | 7 | 6 | 9 | 1 | 5 | 8 | 4 | 3
---------------------------------
3 | 4 | 1 | 7 | 8 | 2 | 9 | 6 | 5
---------------------------------
5 | 9 | 8 | 3 | 4 | 6 | 1 | 7 | 2
---------------------------------
7 | 8 | 9 | 1 | 6 | 3 | 2 | 5 | 4
---------------------------------
4 | 6 | 2 | 5 | 7 | 8 | 3 | 1 | 9
---------------------------------
1 | 3 | 5 | 4 | 2 | 9 | 6 | 8 | 7
---------------------------------
8 | 5 | 7 | 2 | 3 | 1 | 4 | 9 | 6
---------------------------------
6 | 2 | 4 | 8 | 9 | 7 | 5 | 3 | 1
---------------------------------
9 | 1 | 3 | 6 | 5 | 4 | 7 | 2 | 8
This process used 1 ms for its computations
It spent 1 ms in system calls
.
Second solution with HomeMade package
2 | 7 | 6 | 9 | 1 | 5 | 8 | 4 | 3
---------------------------------
3 | 4 | 1 | 7 | 8 | 2 | 9 | 6 | 5
---------------------------------
5 | 9 | 8 | 3 | 4 | 6 | 1 | 7 | 2
---------------------------------
7 | 8 | 9 | 1 | 6 | 3 | 2 | 5 | 4
---------------------------------
4 | 6 | 2 | 5 | 7 | 8 | 3 | 1 | 9
---------------------------------
1 | 3 | 5 | 4 | 2 | 9 | 6 | 8 | 7
---------------------------------
8 | 5 | 7 | 2 | 3 | 1 | 4 | 9 | 6
---------------------------------
6 | 2 | 4 | 8 | 9 | 7 | 5 | 3 | 1
---------------------------------
9 | 1 | 3 | 6 | 5 | 4 | 7 | 2 | 8
This process used 36 ms for its computations
It spent 0 ms in system calls
The logo was inspired by google image