Rapid Java development for PHP programmers
PHP programmers quickly develop Java, just like we are learning java with a magnifying glass. After so many years of development, java can be said to be very huge. The same goes for learning a new language. There are many online tutorials, which are very large and comprehensive. Generally, you have to study systematically for 30 to 60 hours before you can formally contact project development. The basics are very important, but learning too many basics will make everyone lose the fun of learning and self-confidence. Many knowledge points can actually be made up after the project. Learning on demand is the best way to learn driven by yourself.
For example, the hash distribution, hash collision, and dynamic expansion of hashmap, these are what we need to understand in the later stage to improve in depth. In the early stage, we only need to know how to get the hashmap Just do whatever you want.
Oriented to implement things that we are familiar with
For example, when we develop Web back-end APIs, we first start with commonly used loops/iterations, conditional judgments, additions, deletions and modifications. So can we quickly use java to implement these things that we can do very easily with php?
This will help us quickly improve our self-confidence.
Learning method using analogy
How to implement it in PHP, just implement it again in java.
Finally, in-depth systematic study
After you have implemented some small demos, you can refer to other people's projects. If you just look at other people's projects from the beginning, you may have no idea what others are doing. For example, if someone else uses ConcurrentHashMap, then think about why I use HashMap but he uses ConcurrentHashMap. Look at the open source code with questions and thoughts.
After completing some simple projects, you can go back to systematic study. At this time, there will be different gains.
Finally, when the project needs to be tuned and performance improved, break it down individually and learn in depth to be more targeted and targeted.
The actual battle begins
We use netty to provide high-performance web services. It is simple and convenient to use (netty is not simple) and does not depend on other software. Then think about what are the essential components needed to complete a simple web api server. (In fact, when thinking about this, you must keep in mind that making a simple architecture must be done by heart).
I briefly summarized it:
java basic data type (php also has it, don’t be afraid)
java collection framework ( PHP has arrays, very powerful)
First introduction to maven (php has composer)
Reflection (used in framework routing and other places, PHP Also available)
Serialization (used for data transmission, PHP does not have complex data structures and is N times simpler)
jdbc (database operation To use it, php has pdo)
Get a general understanding of generics, annotations and other syntax (optional)
Use netty to actually develop a web api service (php has swoole)
Java basic data structure, various basic data type packaging classes
Java - Collections Framework high-frequency class example
#HashSet is a set without duplicate elements. It is implemented by HashMap and does not guarantee the order of elements, which means that the order of insertion of the elements is inconsistent with the order of output.
This is actually an old friend of mine. It is often used in redis. For example, we can use it to implement a blacklist, so that the search speed is very fast, and there is no need to query redis remotely. It is directly in the current memory. Inquiry.
ArrayList implements the function of a collection based on an array. It maintains a variable-length object array internally. All objects in the collection are stored in this array and realize dynamic expansion and contraction of the length of the array.
Isn’t this the commonly used index array in our PHP?
HashMap is implemented as a hash table data structure. When searching for an object, its position is calculated through a hash function. It is designed for fast query. The characteristics are fast and non-thread-safe.
First introduction to maven
The basic principle of Maven is very simple. It uses remote warehouse and local warehouse and a core configuration file pom.xml. The jar file defined in pom.xml is downloaded from the remote warehouse. To the local warehouse, each project uses the jar of the same local warehouse. The same version of the jar only needs to be downloaded once, and avoids copying the jar for each application.
This is very similar to PHP's package management tool composer, or composer is designed with reference to maven. Maven is more powerful. Composer needs to be imported for each project. Maven, like git, has a local warehouse. Third-party packages will not be directly referenced into the project, but will be introduced during compilation (yes not convenient). On the other hand, maven is not only a package management tool, but also a project management tool that integrates compilation, packaging, unit testing and other functions.
Implement controller access
Specific requirements: provide an api that allows users to specify user information
Definition interface:
http://localhost:10000/users/{id} http://localhost:10000/?method=user.get&id={id}
Perhaps everyone is already accustomed to the former restful api interface.
Because this requires routing mapping and http method matching, considering the cost of learning, I did not choose this method.
Our goal today is to implement our functionality in the simplest and most effective way.
We first implement it in the simplest way (in fact, the API without routing is the fastest, after all, less judgment needs to be made).
The above content is how PHP programmers can quickly develop Java. I hope it can help everyone.
Related recommendations:
A PHP file upload class sharing_php example
php image watermark adding, compressing, and cutting encapsulation Class
The most complete PHP regular expression in history_regular expression
The above is the detailed content of Rapid Java development for PHP programmers. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

Java's platform independence means that the code written can run on any platform with JVM installed without modification. 1) Java source code is compiled into bytecode, 2) Bytecode is interpreted and executed by the JVM, 3) The JVM provides memory management and garbage collection functions to ensure that the program runs on different operating systems.

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.
