irpcpro / testcrud
A project to management Products and Orders
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: ^8.1
- guzzlehttp/guzzle: ^7.2
- laravel/framework: ^10.10
- laravel/sanctum: ^3.3
- laravel/tinker: ^2.8
- mongodb/laravel-mongodb: ^4.3
- tymon/jwt-auth: ^2.1
Requires (Dev)
- fakerphp/faker: ^1.9.1
- laravel/pint: ^1.0
- laravel/sail: ^1.18
- mockery/mockery: ^1.4.4
- nunomaduro/collision: ^7.0
- phpunit/phpunit: ^10.1
- spatie/laravel-ignition: ^2.0
README
Version: 1.0.1
A project for managing Products
& Orders
with JWT
authentication
+ Installation
Install this project via Composer:
composer create-project irpcpro/testcrud
+ Requirements
- PHP:
^8.1
- mongodb/laravel-mongodb:
^4.3
- tymon/jwt-auth:
^2.1
- Redis Driver (windows):
v4.2.1
- MongoDB (windows):
7.2.5
+ MongoDB Installation & Configuration
installing MongoDB
- first you need to install the
MongoDB 7.2.5
for windows. - after installing, you have to insert your DB connection to the
.env
file. to connect the project to the database.
Download MongoDB Extension .dll file
- next step, you have to install the Ext of the MongoDB for PHP and enable it through the
php.ini
file. - for downloading, go to the packages PHP official website, and base on your windows, download the version of the
.dll
which is compatible with your windows and the PHP version which is installed on your PC. - MongoDB PHP Package (https://pecl.php.net/package/mongodb)
Install the extension
- 1- go to your PHP folders where you've installed. (for finding the path of the PHP file, execute this command on CommandPrompt:
where php
) - go to this path and copy the
php_mongodb.dll
{drive}:\php\php-{version}\ext
- next step, you have to add the extension name to
php.ini
file. go to this path and open thephp.ini
file withnotepad
:
{drive}:\php\php-{version}\
- in the part of the
Dynamic Extensions
(you can search it) add this command and save the file and restart your PHP server
..
..
extension=mongodb
- you can check in the terminal to see if it is installed. open your CommandPrompt and run this command :
> php -m | find "mongo"
- the output should be
mongodb
- or just execute this code via PHP :
<?php echo phpinfo(); ?>
config Replica Set and run the database
- first open the
CommandPrompt
as administrator and run this command to start the Replica Set
mongod --dbpath "C:\data\db" --logpath "C:\data\log\mongod.log" --replSet "rs0"
- now, open another
CommandPrompt
as administrator and run this command to enter to the MongoDB environment
mongo
- now you can initiate the Replica and see the status of this with these two commands:
> rs.initiate()
> rs.status()
Debugging
- if you have a problem for running Replica Set and you face a problem like this :
> rs.initiate()
{
"ok" : 0,
"errmsg" : "This node was not started with the replSet option",
"code" : 76,
"codeName" : "NoReplicationEnabled"
}
- it's because you're port of the MongoDB is reserved. and you have to stop the process which is run on the port of
27017
Killing the port
- 1- Open the
CommandPrompt
as administrator. - 2- run this command:
> netstat -aon | find "27017"
. - 3- then you see something like this :
TCP 127.0.0.1:27017 0.0.0.0:0 LISTENING 13936
- 4- the
13936
is thePID
that you have to kill it. - 5- next step, run this command to abort this process:
taskkill /pid {PID} /f
like :
taskkill /pid 13936 /f
+ Redis Installation & Configuration
Installing Redis
- installing Redis v4.2.1 for windows. you can download the release version from the Redis Github
- Redis GitHub (https://github.com/redis-windows/redis-windows)
- after downloading, you have to run 2 service. first run the
redis-server.exe
and next run theredis-cli.exe
- your redis driver is running
Install Redis PHP Extension
- for downloading, go to the packages PHP official website, and base on your windows, download the version of the
.dll
which is compatible with your windows and the PHP version which is installed on your PC. - Redis PHP Package (https://pecl.php.net/package/redis)
Install the extension
- 1- go to your PHP folders where you've intsalled. (for finding the path of the PHP file, execute this command on CommandPrompt:
where php
) - go to this path and copy the
php_redis.dll
{drive}:\php\php-{version}\ext
- next step, you have to add the extension name to
php.ini
file. go to this path and open thephp.ini
file withnotepad
:
{drive}:\php\php-{version}\
- in the part of the
Dynamic Extensions
(you can search it) add this command and save the file and restart your PHP server`
..
..
extension=redis
- you can check in the terminal to see if it is installed. open your CommandPrompt and run this command :
php -m | find "redis"
- the output should be
redis
- or just execute this code via PHP :
<?php echo phpinfo(); ?>
changing the cache driver
- for chaning the
Cache Driver
of the project, if you don't have Redis Driver on your system, open the.env
file and change theCACHE_DRIVER
tofile
like this : CACHE_DRIVER=file
- also you can set it with Redis
CACHE_DRIVER=redis
+ Postman Collection & Environment
- there are the Postman Collection and Environment for importing.
- collections are available on
DEVELOPMENT
folder Collection => DEVELOPMENT/CRUD.postman_collection.json
Environment => DEVELOPMENT/CRUD.postman_environment.json