Subscribe Us

Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

Services in PHP - an Introduction

 





Services : 

when there are operations that need to be represented, but Entities and Value Objects aren't the best place, you should consider modeling these operations as Services. In Domain-Driven Design, there are typically three different types of Services you'll encounter:

Application Services: Operate on scalar types, transforming them into Domain types. A scalar type can be considered any type that's unknown to the Domain Model. This includes primitive types and types that don't belong to the Domain. 

 Domain Services: Operate only on types belonging to the Domain. They contain meaningful concepts that can be found within the Ubiquitous Language. They hold operations that don't fit well into Value Objects or Entities. 

Infrastructure Services: Are operations that fulfill infrastructure concerns, such as sending emails and logging meaningful data. In terms of Hexagonal Architecture, they live outside the Domain boundary.



Application Services

Application Services are the middleware between the outside world and the Domain logic. The purpose of such a mechanism is to transform commands from the outside world into meaningful Domain instructions. 

Let's consider the User signs up to our platform use case. Starting with an outside-in approach: from the delivery mechanism, we need to compose the input request for our Domain operation. Using a framework like Symfony as the delivery mechanism, the code would look something like this:

class SignUpController extends Controller

{

public function signUpAction(Request $request)

{

$signUpService = new SignUpUserService(

$this->get('user_repository')

);

try {

$response = $signUpService->execute(new SignUpUserRequest(

$request->request->get('email'),

$request->request->get('password')

));

} catch (UserAlreadyExistsException $e) {

return $this->render('error.html.twig', $response);

}

return $this->render('success.html.twig', $response);

}

}

 

As you can see, we create a new instance of our Application Services, passing all dependencies needed — in this case, a UserRepository. UserRepository is an interface that can be implemented with any specific technology (Example: MySQL, Redis,  Elasticsearch). Then, we build a request object for our Application Service in order to abstract the delivery mechanism — in this example, a web request — from the business logic. Last, we execute the Application Service, get the response, and use that response for rendering the result. On the Domain side, let's check a possible implementation for the Application Service that coordinates the logic that fulfills the User signs up use case:

class SignUpUserService

{

private $userRepository;

public function __construct(UserRepository $userRepository)

{

$this->userRepository = $userRepository;

}

public function execute(SignUpUserRequest $request)

{

$user = $this->userRepository->userOfEmail($request->email);

if ($user) {

throw new UserAlreadyExistsException();

}

$user = new User(

$this->userRepository->nextIdentity(),

$request->email,

$request->password

);

$this->userRepository->add($user);

return new SignUpUserResponse($user);

}

}

Everything in the code is about the Domain problem we want to solve, and not about the specific technology we're using to solve it. With this approach, we can decouple the high level policies from the low-level implementation details. The communication between the delivery mechanism and the Domain is carried by data structures called DTOs.

 

Domain Services

Throughout conversations with Domain Experts, you'll come across concepts in the Ubiquitous Language that can't be neatly represented as either an Entity or a Value Object,  such as: Users being able to sign into systems by themselves A shopping cart being able to become an order by itself The preceding example are two concrete concepts, neither of which can naturally be bound to either an Entity or a Value Object. Further highlighting this oddity, we can attempt to model the behavior as follows:

class User

{

public function signUp($aUsername, $aPassword)

{

// ...

}

}

class Cart

{

public function createOrder()

{

// ...

}

}

In the case of the first implementation, we're not able to know that the given username and password relate to the invoked-upon user instance. Clearly, this operation doesn't suit this Entity; instead, it should be extracted out into a separate class, making its intention explicit. With this in mind, we could create a Domain Service with the sole responsibility of authenticating users:

class SignUp

{

public function execute($aUsername, $aPassword)

{

// ...

}

}

Similarly, as in the case of the second example, we could create a Domain Service specialized in creating orders from a supplied cart:

class CreateOrderFromCart

{

public function execute(Cart $aCart)

{

// ...

}

}

A Domain Service can be defined as an operation that fulfills a Domain task and  naturally doesn't fit into either an Entity or a Value Object. As concepts that represent operations in the Domain, Domain Services should be used by clients regardless of their run history.

Domain Services don't hold any kind of state by themselves, so Domain Services are stateless operations.

 

Domain Services and Infrastructure Services

It's common to encounter infrastructural dependencies when modeling a Domain Service 

— for example, in the case where an authentication mechanism that handles  password hashing is required. In this instance, you could use a Separated Interface, which allows for multiple hashing mechanisms to be defined. Using this pattern still provides you with a clear Separation of Concerns between the Domain and the Infrastructure: 

namespace Ddd\Auth\Domain\Model;

interface SignUp

{

public function execute($aUsername, $aPassword);

}

Using the preceding interface found in the Domain, we could create an implementation in the Infrastructure layer, like the following:

namespace Ddd\Auth\Infrastructure\Authentication;

class DefaultHashingSignUp implements Ddd\Auth\Domain\Model\SignUp

{

private $userRepository;

public function __construct(UserRepository $userRepository)

{

$this->userRepository = $userRepository;

}

public function execute($aUsername, $aPassword)

{

if (!$this->userRepository->has($aUsername)) {

throw UserDoesNotExistException::fromUsername($aUsername);

}

$aUser = $this->userRepository->byUsername($aUsername);

if (!$this->isPasswordValidForUser($aUser, $aPassword)) {

throw new BadCredentialsException($aUser, $aPassword);

}

return $aUser;

}

private function isPasswordValidForUser(

User $aUser, $anUnencryptedPassword

) {

 

}

}

Here is another implementation based instead on the MD5 algorithm:

namespace Ddd\Auth\Infrastructure\Authentication;

use Ddd\Auth\Domain\Model\SignUp

class Md5HashingSignUp implements SignUp

{

const SALT = 'S0m3S4lT' ;

private $userRepository;

public function __construct(UserRepository $userRepository)

{

$this->userRepository = $userRepository;

}

public function execute($aUsername, $aPassword)

{

if (!$this->userRepository->has($aUsername)) {

throw new InvalidArgumentException(

sprintf('The user "%s" does not exist.', $aUsername)

);

}

$aUser = $this->userRepository->byUsername($aUsername);

if ($this->isPasswordInvalidFor($aUser, $aPassword)) {

throw new BadCredentialsException($aUser, $aPassword);

}

return $aUser;

}

private function salt()

{

return md5(self::SALT);

}

private function isPasswordInvalidFor(

User $aUser, $anUnencryptedPassword

) {

$encryptedPassword = md5(

$anUnencryptedPassword . '_' .$this->salt()

);

return $aUser->hash() !== $encryptedPassword;

}

}

Opting for this choice allows us to have multiple implementations of the Domain  Service interface at the Infrastructure layer. In other words, we end up with several Infrastructure Domain Services. Each Infrastructure service will be responsible for handling a different hash mechanism. Depending on the implementation, the use can easily be managed through a Dependency Injection container — for example, through Symfony's Dependency Injection component:

 

<?xml version="1.0"?>

<container

xmlns="http://symfony.com/schema/dic/services"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="

http://symfony.com/schema/dic/services

http://symfony.com/schema/dic/services/services-1.0.xsd">

<services>

<service id="sign_in" alias="sign_in.default" />

<service id="sign_in.default"

class="Ddd\Auth\Infrastructure\Authentication

\DefaultHashingSignUp">

<argument type="service" id="user_repository"/>

</service>

<service id="sign_in.md5"

class="Ddd\Auth\Infrastructure\Authentication

\Md5HashingSignUp">

<argument type="service" id="user_repository"/>

</service>

</services>

</container>

Share:

Abstract - Network Monitoring System






NETWORK MONITORING SYSTEM


Literature Survey

u A. Basic terminology

Network monitoring tool

Network monitoring tool is the networking tool that is used to examine usage of local area network and provide a statistical data of uploads and downloads in a network. Monitoring tool is usually used to monitor I/P traffic between the LAN and the internet. It is a network diagnostic system that is used to monitor local area network and provide a statistical display of the same. The data can be further used to improve the network efficiency. Other problems such as locating the down server, receiving incorrect work request etc can also be removed.

 

Ø Simple network management protocol

Simple network management protocol (SNMP) is based on agent/manager model. The model consists of an agent, a manager, a database containing information about the management and the network protocols. In SNMP the administrative computer which is more commonly called as manager has the task of monitoring and managing a group of systems in a network. The systems that are managed by the manager have a continuous program running known as agent, which reports the information to the manager via SNMP. Devices such as Routers, printers, servers etc use SNMP.  

WinPcap

u It is a freeware which is used for direct network access under windows.

WinPcap provides architecture for network analyses and packet capturing for win32 platform.

WinPcap can facilitate:

u Raw packet capturing

u Filtering the packets according to the set of rules defined by the user.

u To gather statistical data related to network traffic.

 

B. Why do we need it??

u Network Traffic Monitoring (NTM) is a network analytic tool that observes local area network usage and provides a statistical display of uploads and downloads in a network. The network display monitor displays following information:

u • Source address of the system that sends frame to the network.

u • The protocol that was used to send the frame.

u • Destination address of the system where the frame will be received.

u • Data of the message that is sent.

u Capturing is the process by which a network monitor collects the information.

All the information is stored by default in capture buffer. Also, one can apply restrictions on the information to be captured by the system and the data to be displayed on the monitor. 

u The network monitoring tool is essential to keep the track of the packets that are entering and leaving the system. NMT can provide an statistical data of the network traffic and thus improvements can be made on the system.  

C. Current research and progress

u Microsoft is currently empowering a project to build a network monitoring tool to achieve “State of art”. By introducing this system one can improve network efficiency and monitor the same more efficiently.

u Moreover researches are adopting various techniques, such as use of an

Active measurement system in which a probe traffic is injected into the network and then monitor the performance of the system from the performance of the injected packets.

 

PROBLEM DEFINITION

v PREVIOUS NETWORK MONITORING TOOLS ARE NOT USER FRIENDLY.

v THE SECURITY WAS NOT THE PRIMARY OBJECTIVE.

v RESTORAL CAPABILITIES WERE NOT A BIG ISSUE.

v TRAFFIC REROUTING WAS NOT A PROMINENT FEATURE IN THEIR  INVENTORY. 

 

SYSTEM DESIGN:

u What is it??

System design describes the requirements that are needed by our system. It also emphasis on the operating requirement and the system and its sub system’s architecture. The input/output layout, interphases, detailed design, and processing logic are also covered.

 

Our implementation

We have used UML diagrams to describe operations and functions or our system including its structural and behavioural view  

Use Case Diagram

1) Actors:

• Network: It represents a collection of machines connected to the host machine

and passes the packets from one machine to another.

• NPM Tool: it takes packets from the network, analyzes them and monitors the

network.

• System owner: System owner is the client accessing services from the server.

 

2) Use Cases:

• IP Packets: All the IP packets in the network come to NPM for analyses.

• Alert system: Alerts the system owner if a anomaly is detected.

• Log file: Keep track of the IP address and name of the machine which is stored in

the database.

• Anomaly detection: Detects if there is any deviation from the specified rules.

• Monitors network

• Calculates Bandwidth

• Provides GUI

TOOLS/PROTOCOLS Required

WinPcap

u WinPcap is a free, public system for direct network access under Windows.

WinPcap is an architecture for packet capture and network analysis for the

Win32 platforms.

u The purpose of WinPcap

v Capture raw packets

v Filter the packets according to user-specified rules before dispatching them to

the application

v Transmit raw packets to the network

v Gather statistical values on the network traffic

 

SNMP

u SNMP is based on the manager/agent model consisting of a manager, an agent, a database of management information, managed objects and the network protocol. The manager provides the interface between the human network manager and the management system. The agent provides the interface between the manager and the physical device(s) being managed

u The manager and agent use a Management Information Base (MIB) and a

relatively small set of commands to exchange information.

u SNMP uses five basic messages

v GET

v GET-NEXT

v GET-RESPONSE

v SET

v TRAP

TRAFFIC MONITORING

Main feature of our project is monitoring traffic in the network

Network traffic analyzer

The port numbers are used to identify the application layer

protocols (HTTP,FTP,DNS etc.)

Protocol analyzer

This monitors the protocol used by each system and thus enables to

calculate bandwidth usage.

Bandwidth monitor

Bandwidth is calculated by monitoring the number of packets traverse.

Size of each packet *Number of packets=Value of bandwidth

 

TESTING

Unit Testing

u We did unit testing on our various sub units of the program.

u The function pcap_findalldevs() was tested for the various networks that can

be opened.

u The function Pcap_open_live() was tested to check the working which was to

open the live capture function.

u Pcap_setfilter() was tested to check the association of the filter to a capture.

Integration Testing

u The integration testing produced errors as Unit testing was not a success.

System Testing

u The system testing will be done once we get favorable outcomes from the

Integration testing.

Comparison Testing

u The comparison testing will be done and the output of the software will be

tested with the software which is available in the market.

 

Future Enhancement

Project can be further enhanced to

u Fault management

u Alerts and threshold

u Windows event log monitoring

u Traffic management

u Network Security

u Network scheduling



Share:

Abstract of Three Project

 

 




Abstract of Three Project

Online Payroll System

Objectives of the project:

The main aim of this project is have a fully automated pay-roll system. This fully user friendly software will make the whole pay-roll system speedier and will guarantee on time salary to employees without any redundancy and delays. Moreover, it will certainly reduce the time, money and effort wasted in manual searching for leaves, deductions, grade allocation and designation allocation.

Existing System:

The Existing system is in fact very slow and highly delays prone. As the data stored is done manually, it takes a lot of time to process any query regarding information of any employee. The financial head has to search for a particular employee grade, leaves, designation and calculate the deductions before issuing him the pay slip. It requires huge man power if the organization is having a good number of employees. Due to manual operations, inconsistency in data management may prevail which can create faulty pay slips.

Proposed system:

The proposed software will remove any kind of redundancies and inconsistencies prevailing in the existing system by providing a fully computerized pay roll management system. The software will hold all the employee’s personal details, along with his grade, designation, leaves and other deductions. The reports and the pay slips can be generated with a single mouse click. The GUI of the software is very user friendly, easy to navigate and can easily be managed by a non tech-savvy person.

System specifications:

Modules:

There are essentially two modules of this software which are further broken into sub-modules;

1.      Registration module: In this module, new entries will be created and modified. It is broken into five sub modules:

·         Employee Master: Here all the details of the employee like address, DOB, Date of joining are stored here. He is allotted grade and designation through this module.

·         Deductions master: Here all the deductions will be calculated. Leave deductions, tax deductions and other deductions are inserted here.

·         Department master: New departments are added here and updations and modifications to existing departments are done here.

·         Designation Master: It enables the admin to create new designation corresponding to a particular department.

·         Grade Master: Here new grades can be created as well as allocated to the existing employees.

 

2.      Reports Module: The reports module is responsible for report generation based on the specified category. The categories are employee wise reports, grade wise reports, department wise reports, grade wise repots and pay-slip report. Pay-slip generation is also responsibility of this module.

Hardware configuration

Processor speed          233 MHz or above

RAM                            128 MB

Monitor                       Standard color Monitor

Hard disk                     20 GB

Floppy drive                1.44 MB

CD drive                      32 Hz

Key board                    108 keys keyboard

Mouse                         Scrollable 3 buttons

 

Software configuration

Operating system       Windows 95/98/NT/2000

Language                    Java (JDK), Servlets (JSDK), JavaMail

GUI                              HTML, CSS, JavaScript

Backend                      Oracle

Web Server                 Java Web Server 2.0

Database Connectivity   JDBC

Web Browser                    Internet Explorer

 

 

Online medical Booking Store

Objective:

The main objective of this system is to take the whole medical store online so that it is reachable to customers 24/7. It also aims at going towards cashless transactions. It will impart a wider visibility to the customers. Thus boosting the business to higher levels. The software will be a web based system with a very user friendly interface which indeed will make the whole management process easy to manage and operate with zero redundancies. Overall online medical booking store will become an efficient, highly responsive and an extremely accurate system.

Existing System:

The existing system is time consuming and requires more man power to function well. Secondly the scope of offline medical store is limited to local area and is available for fixed timing. All the data management involving product availability , searching , billing and other report generation are done manually which indeed are very time consuming.

 

Proposed System:

The proposed system will completely Revolutionize the industry. Searching of products, order placing, billing and product stock can be maintained by a single click. The order placed can be easily tracked At any time. The payment of the order can also be done by credit cards.

 

System Specifications:

This system is essentially divides into six modules:

1.    Administrator module: admin has been granted full access with complete permissions towards the system. He is essentially responsible for creating, deleting and modifying any product into the inventory. He has full authority to delete any user account. He can view and send reply to user’s messages. Report generation can be done by admin by selecting a time frame from calendar.

2.    Visitor module: The visitor will be greeted on the home page. He can view about us page and signup/login page. He can navigate around the products but cannot place order.

3.    User module: when a visitor signups for the website, he becomes the user. Now he can not only search around the products but also can place order and do the payment. Change of password and logout are also displayed in this module.

4.    Payment module: payment can also be done by credit cards. The software is so designed that it will not remember the credit card credentials.

5.    Shopping cart module: This module offers to add, delete and modify the products in the cart. After this shopping cart module will be redirected towards payment module.

6.    Discussion Board module: Here communication follows between users and administrator. A user can send messages or complaints to admin and admin sends replies to users.

Hardware Configuration

Operating System                    windows

Modem                                      33.6 kbps

Hard disk                                   40GB

RAM                                            512 MB (server) and 256 MB(client)

Processor.                                   2.77 GHz Pentium 4

Software requirements

 

Software                                            JDK 1.4 J2EE Enterprise edition

Database                                           Oracle

Web server                                       Web Logic 7.0            

database connectivity.                    JDBC/ODBC

GUI.                                                     HTML/CSS

Programming Language.                  Java

 

LIBRARY SYSTEM

Objective:

The primary objective of this library system is to maintain the records of the books and various documents which are available under the library room and to maintain the database of the students who will take the services of their library campus. There will be different type of users who will use this system in order to perform processing task and other administrative task apart from the students. Students will be provided with two options while accessing this system and these two are: Login and Register. For the very first time users (student), they have to register by using this system and their account will be verified by the librarian.                                                                                                                            Processing wok will be handled by the three layers which are tomcat server layer, application server layer which is jdbc odbc and the third one is database layer. Some of the default settings will be enforced while using the system such as listing of requested records in the ascending order and as per category wise. The primary objective of this enforcement is to make easy access to all information. The listing of books will be provided along with their front images with search and browse options. To display the exact location of books, a virtual mapping system has been implemented to find any book easily.

Existing System:

Previously the system was not able to overcome from the problem of data redundancy which in turn increases the burden of background processing. All working departments were not integrated with each other, by which manual work has to be done to make all task done. Any students who have fined, they need to submit their library card for final billing and provide account pay slip to confirm their due fees. Due to this problem students were not free to take out books from library until they have cleared their dues.

Proposed System:

In this new system, the problem of forgetting password or facing problem while login has been resolved and will automatically handle by the system itself. Students will also able to take print out or download pages of particular book either in pdf or in xml format. One to one and one to many relationship has been implemented to eliminate the process of data redundancy and maintain consistency. An inbuilt function within this system will able to provide the entire day transactions for each end day which will improve the auditing process. The CMS part of the library system can be inserted with video lectures which can be accessed by the system or a private messages can be send to the students to make them inform about new books under the library room.

 

 

Share:
Powered by Blogger.

Ad Code

Responsive Advertisement

Ad Code

Responsive Advertisement

Featured post

Search This Blog

Recently added book names

THE HTML AND CSS WORKSHOP   | MICROSOFT POWER BI COOKBOOK   | MongoDB in Action, 2nd Edition  | ADVANCED DEEP LEARNING WITH PYTHON   | Cracking Codes with Python An Introduction to Building and Breaking  | Moris Mano Degital Design 3rd Edition  | Beginning App Development with Flutter by Rap Payne  |react hooks in Action - John Larsen   | Artificial Intelligence A Modern Approach Third Edition Stuart Russel  | Data Structures and Algorithms - Narasimha Karumanchi   | Thomas S.M. - PostgreSQL High Availability Cookbook - 2017  | Gunnard Engebreth PHP 8 Revealed Use Attributes the JIT Compiler   | ICSE Class X Computer Application Notes   | INTERNET OF THINGS PROJECTS WITH ESP32   | 100 aptitude trick(102pgs)s   | OBJECT_ORIENTED_PROGRAMMING Question & Answer   | C questions and answer   | Full_Book_Python_Data_Structures_And_Algorithm   | Jira 8 Administration Cookbook Third Edition  | KALI LINUX WIRELESS PENETRATION TESTING BEGINNERS GUIDE THIRD EDITION - Cameron Buchanan, Vivek Ramachandran  HTML5 & javascript By :- Jeanine Meyer   | Python For Beginners Ride The Wave Of Artificial Intelligence   | HackingTheXbox   | Introduction to Algorithms 3rd.Edition - (CLRS)   | The C++ Programming Language - Bjarne Stroustrup   | Modern C++ Programming Cookbook - Marius Bancila   | Java The Complete Reference Eleventh Edition   Data_Communications and Networking 4th Ed Behrouz A Forouzan   | DevOps with Kubernetes - Hideto Saito   | The-Linux-Command-Line-A-Complete-Introduction   | Assembly Language for X86 Processors KIP R. Irvine   | Effective_Modern_C++ - Scott Meyer

Contact Form

Name

Email *

Message *

Followers

Mobile Logo Settings

Mobile Logo Settings
image

Computer Training School Regd. under Govt. of West Bengal Society Act 1961

Header Ads Widget

Responsive Advertisement

Hot Widget

random/hot-posts

Recent in Sports

Popular Posts

Labels

Blogger templates