Home Backend Development PHP Tutorial PHP Master | Rockmongo for PHP-Powered MongoDB Administration

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

Feb 23, 2025 am 09:28 AM

RockMongo: A powerful PHP MongoDB management tool

RockMongo is an open source MongoDB management tool based on PHP5, allowing the creation of databases, collections, and documents, perform queries, and import and export data. It requires a web server running PHP, the PHP version needs to be 5.1.6 or higher (session support), and the php_mongo MongoDB extension is installed.

Main functions:

RockMongo provides a user-friendly interface for managing databases, collections, documents, indexes, and more. Developers can use it to execute MongoDB commands and JavaScript code, import and export data in multiple formats, and use plugins to extend its functionality. Its functions include: updating, deleting and copying documents; running queries on collections; analyzing queries and their index usage; backing up the database through import/export functions; and supporting plug-in extension functions.

Comparison with other tools:

MongoDB comes with interactive JavaScript-based mongo shell, which can be used to perform database operations. While shell is the best way to start MongoDB querying, GUI management tools are always useful. Many of these GUI tools are available, such as RockMongo, PHPMoAdmin, Fang of Mango, UMongo, MongoExplorer, and MongoVUE, to name just a few. RockMongo and PHPMoAdmin are good choices when using MongoDB with PHP-based projects. This article will focus on RockMongo.

Beginner:

Prerequisites to Run RockMongo:

  1. Web server running PHP
  2. PHP 5.1.6 or later (session support)
  3. MongoDB's php_mongo extension

After you are ready, download the latest version of RockMongo from rockmongo.com/downloads. Installation instructions are available on the RockMongo Wiki, but usually require the downloaded package to be unzipped into a directory accessible to the server site's web and renamed it to rockmongo. Open a web browser and access the index.php page where the RockMongo has been installed.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

The default username and password are "admin" and "admin". If you change your password during installation, enter the corresponding credentials. Click "Login" and you will be redirected to the home page of the RockMongo application.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

As you can see, the home page lists basic information about MongoDB server location and connection, PHP web server, and MongoDB settings. The left panel displays a list of databases and collections.

Create databases and collections:

The Databases tab lists all available databases on the MongoDB server. To create a new database, click Create new database on the Database tab.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

Then enter the name of the database and click "Create" (I named it "rockdb"). The newly created database will appear in the left panel. To create a new collection, click Create under the new database in the left pane and give the collection the name I want (I will use "blog_collection").

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

When providing collection information, there is no need to worry about the "Is Capped" field. It can be safely unchecked.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

The new collection will appear in the left panel under the database. You can click on the collection to list all the documents in it. (Note that when you create the first collection in the database, Mongo DB creates a default system.indexes collection.)

Insert document:

To insert a document, click the Insert tab, and then click the name of the collection.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

We can specify the new document structure as a JSON or PHP array. Choosing either format will not have any impact on the document formed, it is just a matter of developer comfort. After specifying the document, click Save. Likewise, continue inserting other documents.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

To view documents in the collection, click Collections in the left panel and you will see a list of all documents in the content area. The most recently inserted record will be displayed first.

Update, delete and copy documents:

You can update, delete, or copy any document by clicking the corresponding options available on each document. Clicking any link will bring the document to edit mode where you can make changes using JSON or PHP as before.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

Inquiry document:

Querying a database is one of the important functions of any database management tool. Whenever you click on a collection, you find a text area at the top of the page to run the query against it.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

As with documents, query expressions can also be specified as JSON or PHP arrays. There are three operation options in the drop-down menu: findAll, remove and modify.

  • findAll: This is the default option. Specify the lookup criteria and click Submit Query. The matching document will appear in the search results.
  • remove: This is similar to modify, you just specify the criteria for selecting a document, but the action removes the matching document from the collection.
  • modify: When you click modify, you will see two text parts. The first part specifies the conditions to match the document, and the other part specifies the update script. This feature can be used for batch updates.

Using Explain:

This is one of the most useful features and probably my favorite feature in RockMongo. Explain queries are often used to analyze the use of queries and their indexes. As shown below, you can specify a lookup query and click the "Explain" button. This will provide all cursor details for the query.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

Import and export database:

Import and export functions are very useful for backing up databases. The import/export function in RockMongo performs the same tasks as the mongoimport and mongoexport functions. To export a database or collection, click the Export tab. Select all check boxes for the collection you want to export. Also select the Download option and click Export. It will provide you with a downloadable JavaScript file containing the entire exported database.

PHP Master | Rockmongo for PHP-Powered MongoDB Administration

To import data into another database, go to the database and click the Import tab. Select the JS file you just downloaded and the entire dataset will be imported into the database.

Summary:

RockMongo has many other features, which I believe once you start using, you will want to explore. In this article, I've only covered the most commonly used features to help you get started quickly. If you have any questions about this article, please feel free to post your comments!

(The following is FAQ, which has been adjusted and streamlined according to the original text, and the content is maintained consistently)

FAQ:

  • How to install RockMongo? Requires PHP 5.1.6 or higher and MongoDB 1.2.2 or higher. Download the latest version from the official website, unzip the file and upload it to the server. Then, open the config.php file and set up the MongoDB server, port, administrator, and plug-in. Save changes and open RockMongo in your web browser. You should see the login screen where you can enter your administrator credentials.

  • What are the main functions of RockMongo? RockMongo is a powerful PHP-based MongoDB management tool. It provides a user-friendly interface for managing databases, collections, documents, indexes, and more. You can execute MongoDB commands and JavaScript code, import and export data in various formats, and use plugins to extend its functionality.

  • How to create a new database in RockMongo? Click the Database tab in the RockMongo interface and click Create New Database. Enter a name for the database and click Create. The new database will appear in the database list.

  • How to manage MongoDB collections using RockMongo? RockMongo provides a simple interface to manage MongoDB collections. You can create, delete, rename and copy collections, as well as view and modify documents. To manage a collection, click the database name, and then click the collection name.

  • Can I execute MongoDB commands using RockMongo? Yes, RockMongo allows you to execute MongoDB commands and JavaScript code. Click the Tools tab and select Commands. Enter your command in the text box and click Run. The results will be displayed below.

  • How to import and export data using RockMongo? RockMongo supports data import and export in various formats, including JSON, CSV and SQL. To import or export data, click the Tools tab and select Import or Export. Select the format and collection and follow the instructions.

  • How to manage indexes in RockMongo? RockMongo provides a simple interface to manage indexes. To create an index, click the collection name, and then click Index. Enter the index fields and options, and then click Create. To delete an index, click the "Delete" link next to the index name.

  • Can I use the plugin with RockMongo? Yes, RockMongo supports plugins to extend its functionality. You can download plugins from the official website, upload them to the server, and enable them in the config.php file.

  • How to troubleshoot RockMongo? If you encounter RockMongo issues, check the error message and server log for clues. Make sure your MongoDB server is running and accessible and that your PHP version is compatible with RockMongo. If the problem cannot be solved, you can seek help on the RockMongo forum or the GitHub page.

  • Is RockMongo safe? RockMongo uses HTTP basic authentication to protect your MongoDB server. However, it is recommended to use it in a secure network and place the MongoDB server behind the firewall. Always use strong passwords and keep RockMongo and MongoDB versions up to date to prevent security vulnerabilities.

The above is the detailed content of PHP Master | Rockmongo for PHP-Powered MongoDB Administration. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

What are Enumerations (Enums) in PHP 8.1? What are Enumerations (Enums) in PHP 8.1? Apr 03, 2025 am 12:05 AM

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

See all articles