Petrophysical inversion is an important aspect of reservoir modeling. However, due to the lack of a unique and straightforward relationship between seismic traces and rock properties, predicting petrophysical properties directly from seismic data is a complex task. Many studies have attempted to identify the direct end-to-end link using supervised machine learning techniques, but they face challenges such as lack of a large petrophysical training data set or estimates that may not conform with physics or depositional history of the rocks. We present a rock- and wave-physics-informed neural network (RW-PINN) model that can estimate porosity directly from seismic image traces with no wells or with a limited number of wells and with predictions that are consistent with rock physics and geologic knowledge of deposition. The RW-PINN takes advantage of auto-differentiation to compute the gradients across the rock- and wave-physics models. As an example, we use the uncemented-sand rock-physics model and normal-incidence wave physics to guide the learning of the RW-PINN to eventually get good estimates of porosities from normal-incidence seismic traces and limited well data. Training the RW-PINN with few wells (weakly supervised scenario) helps in tackling the problem of nonuniqueness as different porosity logs can give similar seismic traces. We use a weighted normalized root mean square error loss function to train the weakly supervised network and demonstrate the impact of different weights on porosity predictions. The RW-PINN's estimated porosities and seismic traces are compared to predictions from a completely supervised model, which gives slightly better porosity estimates but matches the seismic traces poorly and requires a large amount of labeled training data. We demonstrate the complete workflow for executing petrophysical inversion of seismic data using self-supervised or weakly supervised RW-PINNs.